解决方法:
List> extList = new ArrayList>();
HashMap ext = new HashMap(){
{
put("key", key);
put("value", value);
}
};
extList.add(ext);
StringBuilder sb = new StringBuilder();
sb.append("insert ignore into tb_call_ext(ext_id,c_id,ext_key,ext_val) values(?,?,?,?) ");
int[] extresult = jdbcTemplate.batchUpdate(sb.toString(), new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setString(1, StringUtil.getid());
ps.setString(2, cid);
ps.setString(3, extList.get(i).get("key") + "");
ps.setString(4, extList.get(i).get("value") + "");
}
@Override
public int getBatchSize() {
return extList.size();
}
});