zoukankan      html  css  js  c++  java
  • [mybatis] sql语句无错误,但是执行多条sql语句时,抛出java.sql.SQLSyntaxErrorException

    错误内容

    org.springframework.jdbc.BadSqlGrammarException: 
    ### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: 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 '= '553fe0583195819abb6bf1bd2f03d5f32a17f2238f9d23d6c70f67e947e43b33',
              ' at line 2
    ### The error may involve com.slabs.upload.database.mapper.AgentBillDetailDAO.batchUpdateSealIdByPrimaryKey-Inline
    ### The error occurred while setting parameters
    ### SQL: update agent_bill_detail             seal_id = ?,             is_send = ?,             receive_time = ?             where detail_id = ?          ;              update agent_bill_detail             seal_id = ?,             is_send = ?,             receive_time = ?             where detail_id = ?
    ### Cause: java.sql.SQLSyntaxErrorException: 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 '= '553fe0583195819abb6bf1bd2f03d5f32a17f2238f9d23d6c70f67e947e43b33',
              ' at line 2
    ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 '= '553fe0583195819abb6bf1bd2f03d5f32a17f2238f9d23d6c70f67e947e43b33',
              ' at line 2
    


    解决方法

    本人连接的是mysql数据库,检查sql语法并无错误。而此处为 多条query语句,报错信息指向分号后的第二条语句。
    判断可能是连接的datasource默认只允许执行单个query语句。
    在连接datasource的url后面增加参数allowMultiQueries=true

    url: jdbc:mysql://localhost:3306/node_seal?serverTimezone=UTC&zeroDateTimeBehavior=round&allowMultiQueries=true
  • 相关阅读:
    杂项收集,包括-发邮件、二维码生成、文件下载、压缩、导出excel
    SQL2008删除大量数据
    优秀程序设计的18大原则
    多线程基础
    SQL金典
    [读书笔记]高效程序员的45个习惯:敏捷开发修炼之道
    Unity 查找资源引用工具
    Unity自动生成各种机型分辨率效果工具
    Unity Editor模式 Invoke()函数 失效
    Unity 特效 粒子 自动播放
  • 原文地址:https://www.cnblogs.com/lykbk/p/sfsdff345345345345.html
Copyright © 2011-2022 走看看