mybatis批量更新 allowMultiQueries
来源:互联网 发布:淘宝买家修改评价链接 编辑:程序博客网 时间:2024/06/06 05:08
<!-- 批量更新 -->
<updateid="updatePlanList" parameterType="java.util.List">
<foreachcollection="list" item="item" index="index"open="" close="" separator=";">
updateplan
<set>
<iftest="item.planName != null">
planName = #{item.planName},
</if>
<if test="item.planContent!=null">
planContent= #{item.planContent}
</if>
</set>
whereid=#{item.id}
</foreach>
</update>
一直报错,错误如下
严重: Servlet.service() forservlet [mvc-dispatcher] in context with path [/smallProject] threw exception[Request processing failed; nested exception isorg.springframework.jdbc.BadSqlGrammarException:
### Error updatingdatabase. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You have an error in your SQL syntax; check the manual that corresponds to yourMySQL server version for the right syntax to use near 'update plan
SET planName = '2222',
' at line 8
### The error mayinvolve com.xiaorui.mapper.PlanMapper.updatePlanList-Inline
### The erroroccurred while setting parameters
网上搜索一番,发现这需要修改数据源连接配置
比如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
但是我数据源配置在xml中,报The reference to entity "allowMultiQueries" must end withthe ';' delimiter.错误
<propertyname="url"value="jdbc:mysql://localhost:3306/xiaorui?characterEncoding=UTF-8&allowMultiQueries=true"/>
<property name="username"value="root" />
<property name="password"value="123456" />
<propertyname="driverClassName" value="com.mysql.jdbc.Driver" />
原来&等特殊符号在xml中需要转义
<
<
小于号
>
>
大于号
&
&
和
'
'
单引号
"
"
双引号
修改如下
<propertyname="url"value="jdbc:mysql://localhost:3306/xiaorui?characterEncoding=UTF-8&allowMultiQueries=true" />
<property name="username"value="root" />
<property name="password"value="123456" />
<property name="driverClassName"value="com.mysql.jdbc.Driver" />
但是这样批量更新返回的影响行数就为1
- mybatis批量更新 allowMultiQueries
- mybatis批量更新或者插入的时候必须在数据库连接上打开allowMultiQueries选项
- Mysql批量更新的一个坑-&allowMultiQueries=true允许批量更新
- Mybatis+mysql+allowMultiQueries=true
- Mybatis 批量增加,批量更新
- Mybatis 批量插入、批量更新
- Mybatis批量更新
- Mybatis批量更新
- Mybatis批量更新
- mybatis 批量更新
- mybatis 批量更新
- mybatis 批量更新
- Mybatis批量更新
- Mybatis批量更新
- Mybatis批量更新数据
- Mybatis批量更新
- mybatis批量更新
- Mysql+Mybatis批量更新
- C# TableLayoutPanel 一个很实用的案例
- 盘点•GitHub最著名的20个Python机器学习项目
- C语言实现二叉排序树的基本运算算法
- 栈帧——函数调用,变量在内存中如何存取
- 【脑洞】人工智能是否能主宰未来战争!
- mybatis批量更新 allowMultiQueries
- IDC:2017年Q3全球可穿戴设备总出货量2630万台 小米Fitbit并列第一
- 微信官方提供的生成二维码接口得到的是当前公众号的二维码。
- Uiautomator小记之 Uidevice
- 在此行找到多个注释:
- Caffe源码:relu_layer.cpp
- 安装虚拟机出现的一些问题,总是会让人不知所措。下面总结了几点
- Eclipse(maven)
- 案例分析|链家网大数据平台枢纽——工具链