您的位置:首页 > 数据库 > MySQL

mybaitis批量操作时mysql和orcle数据库的配置

2015-08-25 00:00 639 查看
摘要: multiquery就是个mysql对外提供的连接api里的一个参数。有些语言或客户端实现是写死的,硬编码的,没法改,改了也没效。

oracle和mysql数据库的批量update在mybatis中配置不太一样:

oracle数据库:

<update id="batchUpdate"  parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">                 update test   <set> test=${item.test}+1 </set> where id = ${item.id}
</foreach>
</update>

mysql数据库:

mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true

例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true

<update id="batchUpdate"  parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">                        update test <set> test=${item.test}+1 </set> where id = ${item.id}
</foreach>
</update>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: