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(十一)请求生命周期之CBV与FBV
https://www.cnblogs.com/yuanchenqi/articles/8715364.html FBV FBV(function base views) 就是在视图里使用函数处理请求 ...
- 灰度发布/AB test
背景 互联网产品有一个特点,就是不停的升级,升级,再升级.一般采用敏捷开发的团队,基本上保持每周一次的发布频率,系统升级总是伴随着风险,新旧版本兼容的风险,用户使用习惯突然改变而造成用户流失的风险,系 ...
- 2018-2019 ACM-ICPC, Asia Nanjing Regional Contest
https://codeforces.com/gym/101981 Problem A. Adrien and Austin 贪心,注意细节 f[x]=1:先手必赢. f[x]: 分成两部分(或一部分 ...
- OmniPlan,一款让你无法自拔的项目管理工具(仅适用于MAC系统)
OmniPlan 大家都知道Windows系统可以使用project来方便的管理跟踪项目的各项任务,那么Mac系统有没有这样专业级的项目管理软件了?答案是有,今天给大家推荐的Mac系统下的项目管理 ...
- (二叉树 BFS DFS) leetcode 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...
- (链表 双指针) leetcode 19. Remove Nth Node From End of List
Given a linked list, remove the n-th node from the end of list and return its head. Example: Given l ...
- nginx+keepalived高可用web负载均衡
一:安装环境 准备2台虚拟机,都安装好环境 centos 7keepalived:vip: 192.168.1.112192.168.1.110 nginxip 192.168.1.109 maste ...
- centos7.4+openvpn-2.4.4+easy-rsa-3.0
[生产环境物理机安装]openvpn2.4.4服务搭建,并可以正常运行 服务器内网:172.31.33.64 openvpn:10.8.0.0 本机ifconfig yum install epel- ...
- linux文件或目录权限修改后如何恢复(备份了权限就能恢复)
操作系统 RHEL5 如果你在linux上执行了如下操作chmod -R 777 / 或者 chmod -R 700 /那么恭喜你,你的系统即将崩溃,重启之后,你进不了图形界面,而且很多服务都起不来 ...
- MySQL数据库优化_索引
1.添加索引后减少查询需要的行数,提高查询性能 (1) 建表 CREATE TABLE `site_user` ( `id` ) NOT NULL AUTO_INCREMENT COMMENT '自增 ...