使用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. jenkins执行构建任务报错之java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE

    在执行创建工作空间时候,创建不成功,出现错误?? ......... java.lang.NoSuchFieldError: DEFAULT_USER_SETTINGS_FILE ......... ...

  2. javascript-dom文档对象模型2

    每个标签都是一个对象 一:查找元素 1.直接查找 document.getElementById 根据ID获取一个标签 document.getElementsByName 根据name属性获取标签集 ...

  3. Coursera台大机器学习技法课程笔记15-Matrix Factorization

    很多ML模型用的都是数值特征,那么对于分类特征,该怎么做呢? 以linear network为例:先对特征进行转换,转换成有意义的特征后,再对其进行线性组合 进一步,模型可表示为:使Ein最小,我们就 ...

  4. 关于获取Windows下性能参数的总结

    Windows下特定进程或者所有进程的CPU.物理内存.虚拟内存等性能参数的获取方法小结,包括如何在MFC中以及如何使用C#语言来获取参数. VC API:GlobalMemoryStatus 获取全 ...

  5. python生成器、装饰器、正则

    包子来了[4],被[mayun]吃了! 包子来了[4],被[mahuateng]吃了! 做了两个包子 包子来了[5],被[mayun]吃了! 包子来了[5],被[mahuateng]吃了! 做了两个包 ...

  6. Java编程的逻辑 (32) - 剖析日期和时间

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  7. android studio 3.0之后版本自定义文件名生成apk文件

    修改app模块的build.gradle 在android闭包中添加以下代码 //指定打包后应用名称 android.applicationVariants.all { variant -> v ...

  8. Qwidget+opencv显示图像

    步骤 1. 设置opencv库路径 在.pro文件中添加 INCLUDEPATH += D:/opencv/OpencvMingw/opencv310/include LIBS += D:/openc ...

  9. CentOS 7 之 Docker 安装及操作命令

    Docker 安装 官方网站上有各种环境下的安装指南,比如:CentOS.Ubuntu 和 Debian 系列的安装. 而我们现在主要介绍的是基于 CentOS 7.x 上面的安装. 1.查看是否已经 ...

  10. win10下 Jupyter Notebook不运行python 3怎么办?

    Jupyter Notebook不运行python 3怎么办? 内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用 我已经安装了Python 2的Anaco ...