MySQL连接数据库时,添加语句:“allowMultiQueries=true”的作用:
1.可以在sql语句后携带分号,实现多语句执行。
可以执行批处理,同时发出多个SQL语句。
sql语句
![](https://i-blog.csdnimg.cn/blog_migrate/7e2c9b37435921ba675f53643a0fa44f.png)
不加allowMultiQueries=true之前,会报错
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 '=ticket-1 where id = 1
;
update ticket ticket=ticket-1 wh' at line 1
### The error may exist in file [F:\test\my1\target\classes\mapper\TicketMapper..xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: update ticket ticket=ticket-1 where id = ? ; update ticket ticket=ticket-1 where id = ?
### 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 '=ticket-1 where id = 1
;
update ticket ticket=ticket-1 wh' at line 1
; 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 '=ticket-1 where id = 1
;
update ticket ticket=ticket-1 wh' at line 1
加了之后
![](https://i-blog.csdnimg.cn/blog_migrate/495a02ee5a71d035b53260788deacc92.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a077dd51aab213dfb064dfb2b2656658.png)