jdbc.url,请记得带上我,allowMultiQueries=true

今天被一个MySQL异常纠缠了许久,大概是忘带东西,但是它非得让我带,不带就不让我走...,到底是什么东西呢,请接着放下看:
org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: 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 t_dream_product p,t_dream_product_temp t
       SET p.product_enabled = 0' at line 6
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: 
UPDATE t_dream_product p,t_dream_product_temp t
       SET t.status_value = p.status_value
     WHERE t.pk_id = p.pk_id
      and t.status_value != p.status_value;

    UPDATE t_dream_product p,t_dream_product_temp t
       SET p.product_enabled = 0
     WHERE t.pk_id = p.pk_id
       AND t.keyword  = '0' ;

    UPDATE t_dream_product_temp t, t_dream_product p
       SET t.keyword = 0,t.product_enabled = 0
     WHERE t.pk_id = p.pk_id
       AND p.product_enabled = 0 ;

    delete from t_dream_product_cate 
     where  EXISTS
            (select 1 from t_dream_product p 
              where p.pk_id = t_dream_product_cate.product_id 
               and p.product_enabled = 0);
### Cause: 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 t_dream_product p,t_dream_product_temp t
       SET p.product_enabled = 0' at line 6; bad SQL grammar []; nested exception is 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 t_dream_product p,t_dream_product_temp t
       SET p.product_enabled = 0' at line 6
    at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
    at com.sun.proxy.$Proxy10.update(Unknown Source)

以上是异常的提示信息。

事情经过:在进行更新操作的时候报错:
     当前环境是数据库版本:5.7.12、连接驱动版本:mysql-connector-java-5.1.35.jar
     如果是关键词报错的话,已经将product_enabled 该成enabled、t_enabled之后都不行,
     如果是连接驱动版本的问题,尝试过5.1.34、5.1.41。
     尝试直接将SQL语句放入Navicat执行,结果正常
     尝试修改字段名称,结果报错
     尝试单独执行报错的语句,结果正常的。
     尝试将update下的任意两句sql放一起执行,结果报错,
得出结论:当前配置不支持多条SQL语句同时执行这种写法,并不是表的关键字与数据库冲突,但是这种写法应该是支持的,检查数据库连接配置才发现jdbc.url上没有配置allowMultiQueries=true参数。配置上后,问题迎刃而解。明明记得自己是配置过的,但是现实狠狠地扇了我一个响亮的大嘴巴子。

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值