首页 > 代码库 > Spring jdbc 批量修改
Spring jdbc 批量修改
public int[] updateBatchByjdbc(final List<String[]> ids) {
int[] updateCounts = this.getJdbcTemplate().batchUpdate(
"update CS_ORDER set AUDIT_STATUS=? where id = ?",
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
ps.setString(1, ids.get(i)[0]);
ps.setString(2, ids.get(i)[1]);
}
@Override
public int getBatchSize() {
return ids.size();
}
});
return updateCounts;
}
i=getBatchSize() //决定循环次数
Spring jdbc 批量修改