一个List类型的:
{
}
两个数组类型的:
public int[] updateCompanyType(String[] unitIds, String[] unitType) {
final List<String> list=new ArrayList<String>();
for (int i = 0; i < unitIds.length; i++) {
for (int j = 0; j < unitType.length; j++) {
list.add(unitIds[i]+","+unitType[j]);
}
}
String sql="insert into map_unit_join_type (parentId,unitId,typeId,firstId,secondId,thirdId) values(?,?,?,?,?,?)";
int[] counts=jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter(){
public int getBatchSize() {
return list.size();
}
public void setValues(PreparedStatement ps, int i)throws SQLException {
String[] args=list.get(i).split(",");
ps.setInt(1, Integer.parseInt(args[1]));
ps.setInt(2, Integer.parseInt(args[0]));
ps.setInt(3, Integer.parseInt(args[2]));
ps.setInt(4, Integer.parseInt(args[3]));
ps.setInt(5, Integer.parseInt(args[4]));
ps.setInt(6, Integer.parseInt(args[5]));
}
});
}