文章目录
- 一、Mysql数据库
- 1. Url
- 2. xml映射文件
- 二、Oracle数据库
- 2.1. 关键点
- 2.2. xml映射文件
一、Mysql数据库
关键点:在url后面添加&allowMultiQueries=true
,sql后面添加分号;
1. Url
案例:
url: jdbc:mysql://localhost:3306/afsdb?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&useSSL=false&serverTimezone=CTT&nullCatalogMeansCurrent=true&allowMultiQueries=true
2. xml映射文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gblfy.modular.order.mapper.MysqlMoreInsertMapper"><insert id="mysqlmoreInsert" parameterType="com.gblfy.modular.order.model.request.MysqlMoreInsertParam">insert into sys_user2(user_id, account, name)values (#{paramCondition.userId2}, #{paramCondition.account2}, #{paramCondition.name2});insert into sys_user5(user_id, account, name)values (#{paramCondition.userId5}, #{paramCondition.account5}, #{paramCondition.name5});</insert>
</mapper>
二、Oracle数据库
2.1. 关键点
2.2. xml映射文件
begin
开始 end;
结束
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gblfy.modular.order.mapper.OraclelMoreInsertMapper"><insert id="oraclelmoreInsert" parameterType="com.gblfy.modular.order.model.request.OracleMoreInsertParam">begininsert into hero(SNO, USER_NAME, AGE) values (#{paramCondition.sno}, #{paramCondition.userName}, #{paramCondition.age});insert into hero2(SNO, USER_NAME, AGE) values (#{paramCondition.sno2}, #{paramCondition.userName2}, #{paramCondition.age2});end;</insert>
</mapper>