「Spring」JdbcTemplateのbatchUpdate() を利用するコード

Javaコード
public void addUserBean(List<UserBean> list)
{
final List<UserBean> tpBlist = list;
String sql="insert into user(id,name,isgood)"; +
" values(?,?,?)";
jdbcTemplateMysql.batchUpdate(sql,new BatchPreparedStatementSetter() {

@Override
public int getBatchSize() {
return tpBlist.size();
}
@Override
public void setValues(PreparedStatement ps, int i)
throws SQLException {
ps.setInt(1, tpBlist.get(i).getId());
ps.setString(2, tpBlist.get(i).getName());
ps.setBoolean(3, tpBlist.get(i).isGood());
}
});
}

Java

Posted by arkgame