public void addUserBean(List<UserBean> list) { final List<UserBean> tempBpplist = list; String sql="insert into user(id,name,isgood)" + " values(?,?,?)"; jdbcTemplateMysql.batchUpdate(sql,new BatchPreparedStatementSetter() { @Override public int getBatchSize() { return tempBpplist.size(); } @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setInt(1, tempBpplist.get(i).getId()); ps.setString(2, tempBpplist.get(i).getName()); ps.setBoolean(3, tempBpplist.get(i).isGood()); } }); }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10562.html