@Override public boolean batchUpdatePackageBuyPrizeJdbc( List<BetPlanPackageBuy> buyList) { if (buyList == null || buyList.size() <= 0) { return true; } String upd_sql = "update bet_plan_package_buy set pretax_prize=?,postax_prize=? where id = ?"; PreparedStatement ps = null; try { ps = myBatisTemplateBetCart.getConnection().prepareStatement(upd_sql); int rows = 0; for (BetPlanPackageBuy bt : buyList) { rows = rows + 1; ps.setBigDecimal(1, bt.getPretaxPrize()); ps.setBigDecimal(2, bt.getPostaxPrize()); ps.setLong(3, bt.getId()); ps.addBatch(); if (rows % 1000 == 0) { ps.executeBatch(); } } ps.executeBatch(); } catch (Exception e) { logger.error(e.getMessage(), e); } finally { if (ps != null) { try { ps.close(); } catch (SQLException e) { logger.error(e.getMessage(), e); } } ps = null; } return true; }
JDBC batch update
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326518683&siteId=291194637
Recommended
Ranking