测试环境:win10系统+16G内存+mysql5.7.25
1.创建测试表(表结构如下)
2.插入数据方法
@Override
@Transactional(rollbackFor = Exception.class)
public long batchInsert() {
//初始化1000000条数据
List> data = createList(1000000);
Long startTime = System.currentTimeMillis();
String addSql = "insert into aaa (first, second, three, four,five) VALUES(?,?,?,?,?)";
String updateSql = "update aaa set first = ?,second=?,three=?,four=?,five=? where id = ?";
jdbcTemplate.batchUpdate(addSql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps