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/haiyan123/p/7763710.html models.Book.objects.filter(**kwargs): querySet ...
- Django(五)框架之模板继承和静态文件配置
https://www.cnblogs.com/haiyan123/p/7731959.html 一.模板继承 目的是:减少代码的冗余 语法: {% block classinfo %} {% end ...
- Django(二)框架第一篇基础
https://www.cnblogs.com/haiyan123/p/7701412.html 一个小问题: 什么是根目录:就是没有路径,只有域名..url(r'^$') 补充一张关于wsgiref ...
- webpack 非严格模式设置 npm i babel-plugin-transform-remove-strict-mode
安装插件:npm i babel-plugin-transform-remove-strict-mode 在.babelrc文件的插件项添加:"transform-remove-strict ...
- django2+uwsgi+nginx上线部署到服务器Ubuntu16.04(最新最详细版)
1.前期准备 1.打开Terminal终端,执行以下命令,将项目所需要的依赖包,都记录到一个文件内备用. pip freeze >requirements.txt 2.将项目文件夹→右键→添加压 ...
- 文献笔记:Genome-wide associations for birth weight and correlations with adult disease
该文献纳入了EGG(Early Growth Genetics Consortium)和UK biobank两大数据库,分为欧洲祖先和非欧洲祖先群体.这两个数据用到的样本量分别如下: Early Gr ...
- java键盘中输入q退出
用 java.util.Scanner 如下 public static void main(String[] args) { while(true){ Scanner scan = new Scan ...
- WPF开发的界面调用C++生成的dll文件
以引用d1.dll为例. [生成d1.dll] 文件——新建——项目——Visual C++——Win32项目,选择DLL,点击Finish.在d1.cpp中添加代码 #include "s ...
- 给你的手机加上安全保障,请设置SIM卡PIN码
[手机上了锁,为啥还丢钱?专家支招:设置SIM卡PIN码]智能手机一旦丢失,不仅会带来诸多不便,甚至还会造成个人隐私泄露及财产损失. 然而很多人认为,自己已经设置了手机屏锁.支付密码.指纹锁等防御措施 ...
- CodeForces1051F LCA + Floyd
题意:给定一个10W的无向联通图,和10W的询问,每个询问求任意两点间的距离,限制条件是边数-点数不超过20 一般来说图上任意两点间的距离都会采用Floyd算法直接做,但是这个数据范围显然是不合理的, ...