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

报错如下:

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

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

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

  1. UPDATE goods
  2. SET update_date = '2019-03-19 17:12:30',
  3. update_id = 'defUserId',
  4. enabled = 1,
  5. NAME = '李钢的屏幕维修服务',
  6. py_all = 'ligangdepingmuweixiufuwu',
  7. py_head = 'lgdpmwxfw',
  8. outer_code = '345345345345',
  9. mnemonic_code = '',
  10. del_flag = 0,
  11. enabled_flag = 1,
  12. goods_type_uid = 'a5cd4e8cc75456e7',
  13. url = '',
  14. bar_cide = '',
  15. sale_price = NULL,
  16. integral = 0,
  17. scan_name = '李钢的屏幕维修服务',
  18. brand_uid = '01',
  19. en_name = '李钢的屏幕维修服务'
  20. WHERE
  21. outer_id = '345345345345'
  22. AND tenement_id = 'test_tenement_123';
  23.  
  24. UPDATE goods
  25. SET update_date = '2019-03-19 17:12:30',
  26. update_id = 'defUserId',
  27. enabled = 1,
  28. NAME = '黑莓798',
  29. py_all = 'heimei798',
  30. py_head = 'hm798',
  31. outer_code = '453975973361094656',
  32. mnemonic_code = '',
  33. del_flag = 0,
  34. enabled_flag = 1,
  35. goods_type_uid = 'a5cd4e8cc75456e7',
  36. url = '',
  37. bar_cide = '',
  38. sale_price = NULL,
  39. integral = 0,
  40. scan_name = '黑莓798',
  41. brand_uid = '01',
  42. en_name = '黑莓798'
  43. WHERE
  44. outer_id = '453975973361094656'
  45. AND tenement_id = 'test_tenement_123';
  46.  
  47. UPDATE goods
  48. SET update_date = '2019-03-19 17:12:30',
  49. update_id = 'defUserId',
  50. enabled = 1,
  51. NAME = '测试商品',
  52. py_all = 'ceshishangpin',
  53. py_head = 'cssp',
  54. outer_code = 'CS001',
  55. mnemonic_code = '',
  56. del_flag = 0,
  57. enabled_flag = 1,
  58. goods_type_uid = 'a5cd4e8cc75456e7',
  59. url = '',
  60. bar_cide = '',
  61. sale_price = NULL,
  62. integral = 0,
  63. scan_name = '测试商品',
  64. brand_uid = '01',
  65. en_name = 'test
  66. product'
  67. WHERE
  68. outer_id = 'CS001'
  69. AND tenement_id = 'test_tenement_123'

报错原因:

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

解决方法:

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

需要注意的是:

  1. 加了&allowMultiQueries=true 意为 允许批量更新
  2.  
  3. 但是此时如果再想在spring boot中运行mybatis的时候想打印出来sql,就已经不起作用了。
  4.  
  5. 此时按照
  6. https://www.cnblogs.com/sxdcgaq8080/p/9100178.html
  7. 配置的,在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 异常链

    1.) 常常会想要在捕获一个异常后抛出另一个异常,并且希望把原始异常的信息保存下来,被称为异常链. 2.)Throwable子类在构造器中可以接受一个cause(因由)对象作为参数.这个cause就是 ...

  2. laravel 辅助函数

    数组&对象 1.array_divide() array_divide 函数返回两个数组,一个包含原始数组的健,另一个包含原始数组的值 [$keys, $values] = array_div ...

  3. 【LOJ】#2278. 「HAOI2017」字符串

    题解 好神仙的题啊 感觉转二维平面能想到,算重复情况的方法真想不到啊 通过扒stdcall代码获得的题解QAQQQQ 我们先把\(p_i\)正串反串建出一个AC自动机来 然后我们把s串放在上面跑匹配, ...

  4. ref:linux查看用户登录时间以及命令历史

    ref:https://blog.csdn.net/csdn924618338/article/details/73555725/ 1.查看当前登录用户信息 who命令: who缺省输出包括用户名.终 ...

  5. 001.iSCSI简介

    一 iSCSI简介 Internet小型计算机系统接口是一个机遇TCP/IP的协议,用于通过IP网络仿真SCSI高性能本地存储总线,从而为远程存储设备提供数据传输和管理.作为SAN协议,iSCSI跨本 ...

  6. 使用 jquery jroll2 开发仿qq聊天列表侧滑功能

    由于开发需求,需要做一个类似qq的聊天界面,侧滑弹出单条item右侧菜单,菜单可点击,效果如下图(包括点击事件+长按事件): 1.项目主体dom和css 页面结构比较简单,顶部header做了fixe ...

  7. View 事件分发

    View 事件分发 学习自 <Android开发艺术探索> 官方文档-MotionEvent 事件分发机制漫谈 View的事件分发机制,使我们了解View的工作原理继而学习如何自定义Vie ...

  8. View初探

    View初探 学习自 <Android开发艺术探索> View漫谈 Activity构成了我们的界面但是知识一个空壳子,Activity与View相结合才构成了我们丰富多彩的界面,并且为了 ...

  9. Codeforces Round #505 (Div 1 + Div 2) (A~D)

    目录 Codeforces 1025 A.Doggo Recoloring B.Weakened Common Divisor C.Plasticine zebra D.Recovering BST( ...

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