宜昌高端网站建设,北京做手机网站,网站制作语言有哪些,制作自己网站有什么软件其实allowMultiQueries参数是一个比较基础的参数#xff0c;见名知意 支持多SQL执行的参数。
适用场景
其实这个参数是ORM框架中使用的#xff0c;可能很多人误以为是MySQL的参数#xff0c;其实并不是。
例如下面这个mybatis sql脚本#xff0c;最终生成的SQL应该是多个…其实allowMultiQueries参数是一个比较基础的参数见名知意 支持多SQL执行的参数。
适用场景
其实这个参数是ORM框架中使用的可能很多人误以为是MySQL的参数其实并不是。
例如下面这个mybatis sql脚本最终生成的SQL应该是多个update语句中间用 隔开Mybatis框架对于这种SQL的执行就需要allowMultiQueries true的支持。
update idbatchUpdate parameterTypelist timeout3foreach collectionlist itemitem indexindex open close separator;update t_vouchertrim prefixSET suffixOverrides,if testitem.status ! nullstatus #{item.status},/ifif testitem.price ! nullprice #{item.price},/if/trimwhere id #{item.id}/foreach
/update
如果jdbc url中没有设置allowMultiQueries true这个参数值那当运行过程中执行到上面这种形式的SQL的时候会报错。对应的错误是Mybatis的错误
### Error updating database. Cause: 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 UPDATE t_voucher SETstatus 3, at line 43
### The error may involve com.test.product.mapper.voucherBaseMapper.batchUpdate
### The error occurred while setting parameters
### SQL: UPDATE t_voucher SET status ? WHERE id ? ; UPDATE t_voucher SET status ? WHERE id ?
### Cause: 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 UPDATE t_voucher SETstatus 3, at line 43
; bad SQL grammar []; nested exception is 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 UPDATE t_voucher SETstatus 3