private int save() {
String sql = " insert into bj_pre_casebaseinfo (caseno,applicantitemname,caseapplicanttype,caseapplicant,caseapplicantpapertype,caseapplicantpapercode,caseapplicantmobile,caseapplicantphone," +
" caseapplicantzipcode,caseapplicantemail,caseapplicantaddress,caselinkmanname,legalperson,caselinkmanpapertype,caselinkmanpapercode,caselinkmanmobile,caselinkmanaddress) " +
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
try {
jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement ps, int i) throws SQLException {
ps.setString(1, BjCasebaseinfos.get(i).getCaseno());
ps.setString(2,BjCasebaseinfos.get(i).getApplicantitemname());
ps.setString(3, BjCasebaseinfos.get(i).getCaseapplicanttype());
ps.setString(4, BjCasebaseinfos.get(i).getCaseapplicant());
ps.setString(5, BjCasebaseinfos.get(i).getCaseapplicantpapertype());
ps.setString(6, BjCasebaseinfos.get(i).getCaseapplicantpapercode());
ps.setString(7, BjCasebaseinfos.get(i).getCaseapplicantmobile());
ps.setString(8, BjCasebaseinfos.get(i).getCaseapplicantphone());
ps.setString(9, BjCasebaseinfos.get(i).getCaseapplicantzipcode());
ps.setString(10, BjCasebaseinfos.get(i).getCaseapplicantemail());
ps.setString(11, BjCasebaseinfos.get(i).getCaseapplicantaddress());
ps.setString(12, BjCasebaseinfos.get(i).getCaselinkmanname());
ps.setString(13, BjCasebaseinfos.get(i).getLegalperson());
ps.setString(14, BjCasebaseinfos.get(i).getCaselinkmanpapertype());
ps.setString(15, BjCasebaseinfos.get(i).getCaselinkmanpapercode());
ps.setString(16, BjCasebaseinfos.get(i).getCaselinkmanmobile());
ps.setString(17, BjCasebaseinfos.get(i).getCaselinkmanaddress());
}
@Override
public int getBatchSize() {
return BjCasebaseinfos.size();
}
});
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
传一个List的对象集合
private List BjCasebaseinfos;