Spring JdbcTemplate 批量插入或更新操作

public void insertRefiledBatches(final List refileBatchList,final String createId) {

if(Utils.isNotEmpty(refileBatchList)){
getJdbcTemplate().batchUpdate(INSERT_REFILE_BATCHES_SQL.toString(),new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
RefileBatch refileBatch = refileBatchList.get(i);
ps.setDate(1,new Date(refileBatch.getSchedDate().getTime()));
ps.setInt(2,refileBatch.getSchedHr());
ps.setInt(3,refileBatch.getTarNo());
ps.setString(4,refileBatch.getCxrCD());
ps.setInt(5,refileBatch.getBatchSg());
ps.setString(6,refileBatch.getSegmentsModifiedInd());
ps.setString(7,refileBatch.getSegmentsEatenInd());
ps.setString(8,refileBatch.getReFiledInd());
ps.setString(9,createId);
ps.setString(10,createId);
}
public int getBatchSize() {
               return refileBatchList.size();
           }
});
}
}

你可能感兴趣的:(Spring JdbcTemplate 批量插入或更新操作)