ListMap> paramMaps = new ArrayListMap>();
for(int i = 0; i 100; i++ ){
Map paramMap = new HashMap();
paramMap.put("param1", "param1");
paramMap.put("param2", "param2");
paramMap.put("param3", "param3");
paramMap.put("param4", "param4");
paramMap.put("param5", "param5");
paramMaps.add(paramMap);
}
Map[] paramMap = paramMaps.toArray(new HashMap[paramMaps.size()]);
public void saveSpringJDBC(Map[] paramMap) throws Exception {
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
StringBuffer sql = new StringBuffer();
sql.append("Insert into 表名 ");
sql.append(" (param1, param2, param3, param4) ");
sql.append(" Values ");
sql.append(" (:param1, :param2, :param3, :param4 ");
namedParameterJdbcTemplate.batchUpdate(sql.toString(), paramMap);
}
public void ticketIssueCusInfo(Map[] paramMap) throws Exception{
NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
StringBuffer sql = new StringBuffer();
sql.append(" UPDATE 表名 ");
sql.append(" SET param1= :param1, param2 = :param2 ");
sql.append(" WHERE param3 = :param3");
namedParameterJdbcTemplate.batchUpdate(sql.toString(), paramMap);
}
以上就是本文關(guān)于SpringJDBC批量處理數(shù)據(jù)代碼示例的全部?jī)?nèi)容,希望對(duì)大家有所幫助。感興趣的朋友可以繼續(xù)參閱本站:遠(yuǎn)程數(shù)據(jù)庫的表超過20個(gè)索引的影響詳細(xì)解析、oracle數(shù)據(jù)庫ORA-01196錯(cuò)誤解決辦法分享等,感謝朋友們對(duì)本站的支持!