tomsteven1441
Greedy_Tobby
采纳率0%
2019-03-28 17:45

jdbcTemplate.updateBatch批量删除oracle数据库 数据时候很慢,感觉还是一条条删除的,谁知道怎么回事啊

5

public void afterWrite(List<? extends AwardWait> list) {

        final List<? extends AwardWait> listNew=list;
        String sqlMid="delete from tb_b_hebao_award_import_middle where partition_id=? and batch_sn=? and import_id=?";

        BatchPreparedStatementSetter setterMid = new BatchPreparedStatementSetter(){
            public int getBatchSize(){
               return listNew.size();
            }
            public void setValues(PreparedStatement ps,int i){
                AwardWait awardWait = listNew.get(i);
                try{

                    ps.setString(1, awardWait.getPartition_id().toString());
                    ps.setLong(2, awardWait.getBatch_sn());
                    ps.setLong(3, awardWait.getImport_id());
                    if(i%500==0)
                    {
                        ps.executeBatch();
                    }
                  }catch(Exception e){
                      logger.error("batchInsertWaitAward Exception:",e);
                  }
             }
        };


            jdbcTemplate.batchUpdate(sqlMid, setterMid);



    }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

为你推荐