允許mysql同時插入多條sql語句



當需要同時插入多條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語句



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章