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

猜你喜欢

转载自www.cnblogs.com/poterliu/p/10308698.html