【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
使用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的更多相关文章
- 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 ...
- 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改了.后来还是这个问题 ...
- 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 ...
- 插入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 ...
- 修改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 ...
- 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文件 第二步:执 ...
- Mybatis批量更新报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
批量更新数据,非常简单的一段代码,硬是报错,插入的数据也能显示出来 List<User> userlist = new ArrayList<User>(); userlist. ...
- 求助:springboot调用存储过程并使用了pagehelper分页时报错com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException
存储过程如下: dao层的sql Controller层调用: html页面 没有使用pagehelper分页之前,可以正常使用 使用了pagehelper之后就报错 ### Error queryi ...
- 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 ...
随机推荐
- java 异常链
1.) 常常会想要在捕获一个异常后抛出另一个异常,并且希望把原始异常的信息保存下来,被称为异常链. 2.)Throwable子类在构造器中可以接受一个cause(因由)对象作为参数.这个cause就是 ...
- laravel 辅助函数
数组&对象 1.array_divide() array_divide 函数返回两个数组,一个包含原始数组的健,另一个包含原始数组的值 [$keys, $values] = array_div ...
- 【LOJ】#2278. 「HAOI2017」字符串
题解 好神仙的题啊 感觉转二维平面能想到,算重复情况的方法真想不到啊 通过扒stdcall代码获得的题解QAQQQQ 我们先把\(p_i\)正串反串建出一个AC自动机来 然后我们把s串放在上面跑匹配, ...
- ref:linux查看用户登录时间以及命令历史
ref:https://blog.csdn.net/csdn924618338/article/details/73555725/ 1.查看当前登录用户信息 who命令: who缺省输出包括用户名.终 ...
- 001.iSCSI简介
一 iSCSI简介 Internet小型计算机系统接口是一个机遇TCP/IP的协议,用于通过IP网络仿真SCSI高性能本地存储总线,从而为远程存储设备提供数据传输和管理.作为SAN协议,iSCSI跨本 ...
- 使用 jquery jroll2 开发仿qq聊天列表侧滑功能
由于开发需求,需要做一个类似qq的聊天界面,侧滑弹出单条item右侧菜单,菜单可点击,效果如下图(包括点击事件+长按事件): 1.项目主体dom和css 页面结构比较简单,顶部header做了fixe ...
- View 事件分发
View 事件分发 学习自 <Android开发艺术探索> 官方文档-MotionEvent 事件分发机制漫谈 View的事件分发机制,使我们了解View的工作原理继而学习如何自定义Vie ...
- View初探
View初探 学习自 <Android开发艺术探索> View漫谈 Activity构成了我们的界面但是知识一个空壳子,Activity与View相结合才构成了我们丰富多彩的界面,并且为了 ...
- Codeforces Round #505 (Div 1 + Div 2) (A~D)
目录 Codeforces 1025 A.Doggo Recoloring B.Weakened Common Divisor C.Plasticine zebra D.Recovering BST( ...
- AIM Tech Round 3 (Div. 1) A. Letters Cyclic Shift 贪心
A. Letters Cyclic Shift 题目连接: http://www.codeforces.com/contest/708/problem/A Description You are gi ...