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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM