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,即可,如下图: