在使用JDBC操作多条数据库语句的时候,抛出异常
String sql = "set foreign_key_checks = 0; \n" +
"delete from `jobs` where `job_id` = 'AC_ACCOUNT' and job_title = 'Public Accountant' and min_salary = '4200' and max_salary = '9000';\n" +
"set foreign_key_checks = 1;";
JDBCUtils.update(sql);
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 'delete from jobs where job_id = ‘AC_ACCOUNT’ and job_title = ‘Public Account’ at line 2

但是同样的sql语句在sql数据库中可以执行,语法没有问题。想了一个多小时没解决。后来百度了一下,原来要在配置文件中加上&allowMultiQueries=true。

加上以后再运行就可以了


1936

被折叠的 条评论
为什么被折叠?



