2023年6月21日发(作者:)
使⽤jdbctemplate进⾏SQL批量插⼊namedParameterJdbcTemplate使⽤起来更加⼈性化。@Repositorypublic class BatchFooDao { @Autowired private JdbcTemplate jdbcTemplate; @Autowired private NamedParameterJdbcTemplate namedParameterJdbcTemplate; public void batchInsert() { pdate("INSERT INTO FOO (BAR) VALUES (?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ing(1, "b-" + i); } @Override public int getBatchSize() { return 2; } }); List
2023年6月21日发(作者:)
使⽤jdbctemplate进⾏SQL批量插⼊namedParameterJdbcTemplate使⽤起来更加⼈性化。@Repositorypublic class BatchFooDao { @Autowired private JdbcTemplate jdbcTemplate; @Autowired private NamedParameterJdbcTemplate namedParameterJdbcTemplate; public void batchInsert() { pdate("INSERT INTO FOO (BAR) VALUES (?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ing(1, "b-" + i); } @Override public int getBatchSize() { return 2; } }); List
发布评论