Mysql的避坑---- The error may involve defaultParameterMap #The error occurred while setting parameters

Mysql的避坑---- Mysql 数据库连接添加  allowMultiQueries=true属性

最近做项目时,发现操作数据库时 sql报错,如下:

### 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 'delete from sys_user_role where user_id in 
         (  
            6
         )' at line 6
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: delete from sys_user where user_id in     (      ?    )    ;   delete from sys_user_role where user_id in     (      ?    )
### 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 'delete from sys_user_role where user_id in 
         (  
            6
         )' 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 'delete from sys_user_role where user_id in 
         (  
            6
         )' at line 6
 

mybatis的mapper的xml中 使用一个业务 操作两条sql的情况,出现以上的错误,将sql 语句拿到 navicat 执行,都可以执行,纳闷了很久。

主要原因:需要在创建数据库链接时,将允许 多条sql执行设置为 true,即可,如下图:

 

 

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值