使用mybatis进行批量更新操作:

报错如下:

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
goods g
SET
update_date = '2019-03-19 17:16:05.918',
updat' at line 28

但是检查了以后,28行并没有错误

使用【https://www.cnblogs.com/sxdcgaq8080/p/9100178.html】 打印了sql,发现sql如下,也没有问题:

UPDATE goods
SET update_date = '2019-03-19 17:12:30',
update_id = 'defUserId',
enabled = 1,
NAME = '李钢的屏幕维修服务',
py_all = 'ligangdepingmuweixiufuwu',
py_head = 'lgdpmwxfw',
outer_code = '345345345345',
mnemonic_code = '',
del_flag = 0,
enabled_flag = 1,
goods_type_uid = 'a5cd4e8cc75456e7',
url = '',
bar_cide = '',
sale_price = NULL,
integral = 0,
scan_name = '李钢的屏幕维修服务',
brand_uid = '01',
en_name = '李钢的屏幕维修服务'
WHERE
outer_id = '345345345345'
AND tenement_id = 'test_tenement_123'; UPDATE goods
SET update_date = '2019-03-19 17:12:30',
update_id = 'defUserId',
enabled = 1,
NAME = '黑莓798',
py_all = 'heimei798',
py_head = 'hm798',
outer_code = '453975973361094656',
mnemonic_code = '',
del_flag = 0,
enabled_flag = 1,
goods_type_uid = 'a5cd4e8cc75456e7',
url = '',
bar_cide = '',
sale_price = NULL,
integral = 0,
scan_name = '黑莓798',
brand_uid = '01',
en_name = '黑莓798'
WHERE
outer_id = '453975973361094656'
AND tenement_id = 'test_tenement_123'; UPDATE goods
SET update_date = '2019-03-19 17:12:30',
update_id = 'defUserId',
enabled = 1,
NAME = '测试商品',
py_all = 'ceshishangpin',
py_head = 'cssp',
outer_code = 'CS001',
mnemonic_code = '',
del_flag = 0,
enabled_flag = 1,
goods_type_uid = 'a5cd4e8cc75456e7',
url = '',
bar_cide = '',
sale_price = NULL,
integral = 0,
scan_name = '测试商品',
brand_uid = '01',
en_name = 'test
product'
WHERE
outer_id = 'CS001'
AND tenement_id = 'test_tenement_123'

报错原因:

是因为spring boot配置文件中,关于数据库的连接配置,并没有允许进行批量更新的操作

解决方法:

将数据库配置修改为 
jdbc.url=jdbc:mysql://127.0.0.1:3306/datebase?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true 新增了 &allowMultiQueries=true 意为 允许批量更新

需要注意的是:

加了&allowMultiQueries=true 意为 允许批量更新

但是此时如果再想在spring boot中运行mybatis的时候想打印出来sql,就已经不起作用了。

此时按照
https://www.cnblogs.com/sxdcgaq8080/p/9100178.html
配置的,在spring boot中打印sql语句,就无效了

【mybatis】mybatis进行批量更新,报错: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的更多相关文章

  1. 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 ...

  2. SQL语句报错:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near

    报错如图: 最开始其实我的列名tname和tsubject分别叫name和subject,后来看到网上有说这个报错可能是数据库建表的时候使用了mysql的关键词,我就只把name改了.后来还是这个问题 ...

  3. myBatis查询报错 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查询报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL se ...

  4. 插入mysql语句报错:1064 - 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

    插入一个很简单的sql语句时候,mysql一直报错: [SQL] INSERT INTO ORDER ( id, activity_id, order_type, phone, order_amoun ...

  5. 修改mysql密码报错: 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 '

    使用这种格式报错: 格式:mysql> set password for 用户名@localhost = password('新密码'); 找到另一种方法解决: ALTER USER 'root ...

  6. Django进行数据迁移时,报错:(1064, "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 '(6) NOT NULL)' at line 1")

    进行数据迁移时: 第一步: 命令:python manage.py makemigrations 在对应的应用里面的migrations文件夹中产生了一个0001_initial.py文件 第二步:执 ...

  7. Mybatis批量更新报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

    批量更新数据,非常简单的一段代码,硬是报错,插入的数据也能显示出来 List<User> userlist = new ArrayList<User>(); userlist. ...

  8. 求助:springboot调用存储过程并使用了pagehelper分页时报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

    存储过程如下: dao层的sql Controller层调用: html页面 没有使用pagehelper分页之前,可以正常使用 使用了pagehelper之后就报错 ### Error queryi ...

  9. 5.7版本mysql查询报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:...this is incompatible with sql_mode=only_full_group_by

    先瞧下日志: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException ...

随机推荐

  1. java 异常与记录日志

    一. 你可能还想利用java.util.logging工具将输出记录到日志中 package exceptions; //: exceptions/LoggingExceptions.java // ...

  2. 使用abstract关键字的使用

    package abstract1.demo01; //使用abstract关键字修饰的类叫做抽象类public abstract class Father { public static void ...

  3. 一个浏览器Fuzzing框架的学习

    一个浏览器Fuzzing框架的学习 关于框架 之前是LCatro师傅在小密圈分享的他写的这个Fuzzing框架(不过我以前翻github时好像就看到过),但是之前一直没啥时间搞这方面,这两天研究学习了 ...

  4. Taints和Tolerations联用,将pod部署到k8s的master节点

    一般,k8s的master为了保持高性能,在这个主节点上只运行一些管理必须的POD. 如果我们限于资源,或是一些监控类的pod要部署到master节点呢? 昨天遇到这个问题,按网上通用的方法,未解决, ...

  5. angular和vue双向数据绑定

    angular和vue双向数据绑定的原理(重点是vue的双向绑定) 我在整理javascript高级程序设计的笔记的时候看到面向对象设计那章,讲到对象属性分为数据属性和访问器属性,我们平时用的js对象 ...

  6. windows下安装mysql8.0压缩版

         下面总结下安装过程: 首先解压下载好的压缩版本. 将解压后mysql的bin文件目录配置系统环境path变量中 使用cmd打开命令窗口,输入mysqld  --initialize命令初始化 ...

  7. MySQL查询语句执行过程及性能优化-基本概念和EXPLAIN语句简介

    网站或服务的性能关键点很大程度在于数据库的设计(假设你选择了合适的语言开发框架)以及如何查询数据上. 我们知道MySQL的性能优化方法,一般有建立索引.规避复杂联合查询.设置冗余字段.建立中间表.查询 ...

  8. P3905 道路重建

    P3905 道路重建我一开始想错了,我的是类似kruskal,把毁坏的边从小到大加,并且判断联通性.但是这有一个问题,你可能会多加,就是这条边没用,但是它比较小,你也加上了.居然还有10分,数据也是水 ...

  9. ubantu18.04下Hadoop安装与伪分布式配置

    1  下载 下载地址:http://mirror.bit.edu.cn/apache/hadoop/common/stable2/ 2 解压 将文件解压到 /usr/local/hadoop cd ~ ...

  10. 微信小程序之下拉刷新,上拉加载更多

    近日开发微信小程序,发现上拉加载更多没有友好的API,而下拉刷新很nice,所以本人按照API,很简单的写了一个示例,希望对大家有帮助,本人用的是iview-webapp  小程序UI框架. 1. 首 ...