【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 ...
随机推荐
- Objective-C 与JAVA的SHA1/HmacSHA1加密算法实现
最近研究IOS手机上登录的功能.由于加密方式使用SHA1算法.网上也没找到直接的例子,最终参照StackoverFlow上的大神,完成了加密实现. 先上代码: //HmacSHA1加密: +(NSSt ...
- Faster R-CNN在GPU下的安装、测试经历
在公司的服务器上安装faster rcnn时,遇到了不少问题: 1.cudnn版本不兼容的问题,解决办法参考: http://blog.csdn.net/WoPawn/article/details/ ...
- Sqlserver在现有数据库中插入数据
需求:1.客户提供的excel表和数据库中的表结构总是有一些差距,id的生成,各种字段的关联等等 2. 如何在Excel中生成Guid. 1.在Excel的宏中执行以下代码: Private Decl ...
- #CSS margin-top父元素下落
[我的解决方法] 给该父元素添加如下代码 border-top: 1px solid rgba(0,0,0,0); box-sizing:border-box; [原因] css2.1盒模型中规定的内 ...
- vuejs递归组件
vuejs学习--递归组件 前言 学习vue有一段时间了,最近使用vue做了一套后台管理系统,其中使用最多就是递归组件,也因为自己对官方文档的不熟悉使得自己踩了不少坑,今天写出来和大家一起分享. ...
- linux 时间戳
一.https://www.cnblogs.com/33debug/p/6632172.html 二.显示前一小时时间 date -d '-1 hour' '+%F-%H-%M-%S'
- Flume分布式日志收集系统
1.flume是分布式的日志收集系统,把收集来的数据传送到目的地去.2.flume里面有个核心概念,叫做agent.agent是一个java进程,运行在日志收集节点.通过agent接收日志,然后暂存起 ...
- JSP中的Java代码和内置对象
一.JSP中的Java代码 (一)JSP页面中有三种方式嵌入java代码: 1.java的表达式 格式:<%= java表达式 %> 2.java的语句 格式:<% java语句&g ...
- Codeforces Round 542 (Div. 2)
layout: post title: Codeforces Round 542 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Java对epub电子书类型切割
Epub电子书切割 引言:由于公司存储电子书的格式是.epub.一本电子书加载的时候,如果电子书大的话,全部加载该电子书会非常的消耗时间和资源.非常的不合理.那么现在,将所有电子书按章切分.将拆分的电 ...