mybatis批量更新报错
批量更新sql
<update id="updateAutoAppraiseInfo" parameterType="Object">
		<foreach collection="appraises" item="appraise" index="appraises" separator=";">
			UPDATE project_auto_appraise SET
			<trim suffixOverrides=",">
				<if test="appraise.artificialValuation != null and appraise.artificialValuation != '' ">
					artificial_valuation=#{appraise.artificialValuation},
				</if>
				<if test="appraise.difference != null and  appraise.difference != ''">
					difference=#{appraise.difference},
				</if>
				<if test="appraise.remark != null and  appraise.remark != ''">
					remark=#{appraise.remarks},
				</if>
			</trim>
			WHERE sum_project_id=#{sumProjectId} AND media_code = #{appraise.mediaType}
		</foreach>
	</update>
看起来并没有什么问题,但是运行会发现报错,错误信息如下
org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE project_auto_appraise SET
			 artificial_valuation=201 
			WHERE sum_proj' at line 5
### The error may involve com.jd.dlink.dao.mapper.project.ProjectAutoAppraiseMapper.updateAutoAppraiseInfo-Inline
### The error occurred while setting parameters
### SQL: UPDATE project_auto_appraise SET     artificial_valuation=?     WHERE sum_project_id=? AND media_code = ?    ;     UPDATE project_auto_appraise SET     artificial_valuation=?     WHERE sum_project_id=? AND media_code = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE project_auto_appraise SET
			 artificial_valuation=201 
			WHERE sum_proj' at line 5
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE project_auto_appraise SET
			 artificial_valuation=201 
			WHERE sum_proj' at line 5
调试之后,发现只要传一个值进去就没有问题,就是list的成员只有一个。就想着是数据库配置的问题
将数据库配置修改为 jdbc.url=jdbc:mysql://127.0.0.1:3306/datebase?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true
新增了 &allowMultiQueries=true 意为 允许批量更新
就 ok 了
mybatis批量更新报错的更多相关文章
- druid + mysql + mybatis 批量更新报错
		首先 批量更新报错 sql injection violation, multi-statement not allow 然后看了博客:https://blog.csdn.net/qq_3634595 ... 
- mybatis批量更新报错badsql
		mybatis批量更新时语法写的都对,但是报错,需要在连接上面加上allowMultiQueries=true 示例:jdbc:MySQL://192.168.1.236:3306/test?useU ... 
- mybatis批量更新报错 org.mybatis.spring.MyBatisSystemException
		具体报错信息: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.Bin ... 
- Mybatis批量更新报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
		批量更新数据,非常简单的一段代码,硬是报错,插入的数据也能显示出来 List<User> userlist = new ArrayList<User>(); userlist. ... 
- mybatis批量插入报错
		报错内容 org.springframework.jdbc.UncategorizedSQLException: ### Error updating database. Cause: java.sq ... 
- 解决Oracle+Mybatis批量插入报错:SQL 命令未正确结束
		Mybatis批量插入需要foreach元素.foreach元素有以下主要属性: (1)item:集合中每一个元素进行迭代时的别名. (2)index:指定一个名字,用于表示在迭代过程中,每次迭代到的 ... 
- Mybatis批量insert报错的解决办法【the right syntax to use near '' at line...】
		Java中使用Mybatis批量插入数据时Mapper.xml中的sql如下: <insert id="batchSave"> into t_emp(emp_name, ... 
- mybatis批量新增报错 BadSqlGrammarException
		org.springframework.jdbc.BadSqlGrammarException: ### Error updating database. Cause: com.mysql.jdbc. ... 
- mybatis批量更新update-设置多个字段值 报错   You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
		mybatis批量更新update-设置多个字段值 2016年08月01日 12:49:26 姚一号 阅读数:29539 标签: mysql mybatis批量更新批量更新allowMultiQuer ... 
随机推荐
- Django(四)框架之第三篇模板语法
			https://www.cnblogs.com/yuanchenqi/articles/6083427.htm https://www.cnblogs.com/haiyan123/p/7725568. ... 
- host访问goole
			https://laod.cn/hosts/2016-google-hosts.html http://whosmall.com/?post=148 
- apache安装及相应配置
			给公司装过环境,自己也装过自己的服务器环境.但是每次都是现谷歌,毕竟每个人遇到的问题都不一样,还是记录下,以防忘记 一.安装 Centos7默认已经安装httpd服务,只是没有启动.如果你需要全新安装 ... 
- Python递归_打印节点信息
			Python递归_打印节点信息 递归特性:1.必须由一个明确的结束条件2.每次进入更深一层递归时,问题规模相比上一次递归都应该有所减少3.递归效率不高,递归层次过多会导致栈溢出(在计算机中,函数调用时 ... 
- Java父类与子类方法调用顺序
			父类 FatherClass package 父类与子类方法调用顺序; /** * 父类 * @author shundong * */ public class FatherClass { priv ... 
- Oracle基础--创建临时表空间/表空间/创建用户/授权
			总结:创建用户一般分四步: 第一步:创建临时表空间(创建用户之前要创建"临时表空间",若不创建则默认的临时表空间为temp.) SQL> CREATE TEMPORARY T ... 
- 安装FreeIPA以及应用时报错汇总
			安装FreeIPA以及应用时报错汇总 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.ERROR DNS zone yinzhengjie.org.cn already exis ... 
- MyBatis-generator-Maven方式
			一.配置依赖 1.依赖信息 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project x ... 
- sqlserver修改计算机名称。
			SELECT @@SERVERNAME As [@@SERVERNAME], CAST(SERVERPROPERTY('MACHINENAME') AS VARCHAR(128)) + COALESC ... 
- Kafka技术内幕 读书笔记之(三) 生产者——消费者:高级API和低级API——基础知识
			1. 使用消费组实现消息队列的两种模式 分布式的消息系统Kafka支持多个生产者和多个消费者,生产者可以将消息发布到集群中不同节点的不同分区上:消费者也可以消费集群中多个节点的多个分区上的消息 . 写 ... 
