1 public void start(){ 2 String sql = "insert into a(a1,b1) values(?,?)"; 3 final List<Map<String, Object>> list = new ArrayList<Map<String,Object>>(); 4 BatchPreparedStatementSetter pss = new BatchPreparedStatementSetter() { 5 6 public void setValues(PreparedStatement ps, int i) throws SQLException { 7 Map<String, Object> para = list.get(i); 8 String a1 = para.get("a1")!=null?para.get("a1").toString():"0"; 9 ps.setInt(1,Integer.valueOf(a1)); 10 } 11 12 public int getBatchSize() { 13 return list.size(); 14 } 15 }; 16 getJdbcTemplate().batchUpdate(sql, pss); 17 }
public void start(){
String sql = "insert into a(a1,b1) values(?,?)";
final List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();
BatchPreparedStatementSetter pss = new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i) throws SQLException {
Map<String, Object> para = list.get(i);
String a1 = para.get("a1")!=null?para.get("a1").toString():"0";
ps.setInt(1,Integer.valueOf(a1));
}
public int getBatchSize() {
return list.size();
}
};
getJdbcTemplate().batchUpdate(sql, pss);
}