mybatis执行批量更新batch update 的方法(oracle,mysql)
2015-11-28 18:50
609 查看
oracle和mysql数据库的批量update在mybatis中配置不太一样:
oracle数据库:
<updateid="batchUpdate" parameterType="java.util.List">
<foreach collection="list"item="item"index="index"open="begin"close="end;"separator=";">
updatetest
<set>
test=${item.test}+1
</set>
whereid = ${item.id}
</foreach>
</update>
mysql数据库:
mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true
例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
oracle数据库:
<updateid="batchUpdate" parameterType="java.util.List">
<foreach collection="list"item="item"index="index"open="begin"close="end;"separator=";">
updatetest
<set>
test=${item.test}+1
</set>
whereid = ${item.id}
</foreach>
</update>
mysql数据库:
mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true
例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
<updateid="batchUpdate" parameterType="java.util.List"> <foreach collection="list"item="item"index="index"open=""close=""separator=";"> updatetest <set> test=${item.test}+1 </set> whereid = ${item.id} </foreach> </update>
相关文章推荐
- Oracle程序包
- oracle数据字典
- oracle 00845,修改memory_target大小
- java学习笔记:通过JDBC技术获取Oracle数据库连接
- Oracle常用查看表结构命令
- Oracle数据库合并行记录,WMSYS.WM_CONCAT 函數的用法
- 关于使用navicat创建oracle触发器
- oracle复杂查询21道题精析
- ORACLE(PL/SQL) 根据字符分割(SPLIT)字符串返回数组
- RHEL7.0 安装Oracle 11gR2报错解决
- Oracle ASM操作管理
- oracle系列--基础理论
- Oracle学习笔记--导航
- Oracle的入门及一些基本操作
- 本人对Oracle Order Manager模块的一些了解
- 138 Your database instance is running. You are not able to access Oracle Enterprise Manager Database
- oracle创建表空间和用户
- 完全卸载oracle步骤
- ORACLE配置tnsnames.ora文件实例
- Oracle的入门及一些基本操作