mysql的jdbc.url携带allowMultiQueries=true参数的作用及其原理

如下配置

jdbc.url=jdbc:mysql://127.0.0.1:3306/chubb_2?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true

 

allowMultiQueries=true参数的作用:

①可以在sql语句后携带分号,实现多语句执行。

如:mybatis的mapper.xml文件

<select id="getAll" resultType="com.xxx.XBean">
    SELECT * FROM x;
</select>

 

②可以执行批处理,同时发出多个SQL语句。

<update id="batchUpdate"  parameterType="java.util.List">
   <foreach collection="devRelDOList" item="devRelDO" separator=";" open="" close="" >
       UPDATE
           dev_rel
       <set>
           gmt_modified=now(),
           pro_id = #{devRelDO.proId},
           dev_id = #{devRelDO.devId},
           group_id = #{devRelDO.groupId},
           own_type = #{devRelDO.ownType}
       </set>
       <where>
           id = #{devRelDO.id}
       </where>
   </foreach>
</update>

 

 

底层原理:

 

 

 

参考:

https://my.oschina.net/zhuguowei/blog/411853

https://blog.csdn.net/xuezhezhishen/article/details/78692698

 https://my.oschina.net/freedemon/blog/1813816

https://www.cnblogs.com/jeffen/p/6038261.html

https://blog.csdn.net/qq_26718271/article/details/65629805

 

转载于:https://www.cnblogs.com/poterliu/p/10308698.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值