mysql批量insert

1、真正的批量insert,需要在配置里加上rewriteBatchedStatements=true和allowMultiQueries=true
例如:
jdbc:mysql://localhost:3306/shopping?serverTimezone=UTC&rewriteBatchedStatements=true&allowMultiQueries=true

2、此时jdbcTemplate.batchUpdate不再是一条一条insert,而是一句insert插入多条
但是它的返回值数组里,全是返回-2,如果代码有判断返回值需要修改
 

猜你喜欢

转载自blog.csdn.net/csj50/article/details/131644557