首页 > 代码库 > jdbcTemplate批量添加

jdbcTemplate批量添加

技术分享
public void addSubscibe(List<PermedipUserSubscribeVo> list) {        final List<PermedipUserSubscribeVo> vos=list;          String sql="insert into permedip_user_subscribe(user_id,channel_name) values(?,?)";          jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {                        @Override            public void setValues(PreparedStatement ps, int i) throws SQLException {                ps.setInt(1, vos.get(i).getUserId());                ps.setString(2, vos.get(i).getChannelName());            }                        @Override            public int getBatchSize() {                return vos.size();            }        });    }
View Code

 

jdbcTemplate批量添加