当需要同时插入多条sql或一个sql中通过分号分割(或包含)了多个独立sql的话,如:
select 'hello';select 'world'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax
默认allowMultiQueries为false就会报上述错误,当若显式设置allowMultiQueries为true,如:
String url = "jdbc:mysql://localhost:3306?allowMultiQueries=true"
可以同时插入多条sql语句
MySQL多SQL语句执行
本文介绍了在MySQL中如何通过设置allowMultiQueries参数为true来实现一次执行多条SQL语句的方法,避免了因默认设置导致的语法错误。
2817

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



