您的位置:首页 > 博客中心 > 数据库 >

Spring jdbc 批量修改

时间:2022-03-14 02:39

public int[] updateBatchByjdbc(final List<String[]> ids) {
        int[] updateCounts = this.getJdbcTemplate().batchUpdate(
                "update CS_ORDER set AUDIT_STATUS=? where id = ?",
                new BatchPreparedStatementSetter() {

                    @Override
                    public void setValues(PreparedStatement ps, int i)
                            throws SQLException {
                        ps.setString(1, ids.get(i)[0]);
                        ps.setString(2, ids.get(i)[1]);
                    }

                    @Override
                    public int getBatchSize() {
                        return ids.size();
                    }
                });
        return updateCounts;
    }

i=getBatchSize()  //决定循环次数

热门排行

今日推荐

热门手游