@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分批更新
最新推荐文章于 2022-11-07 20:16:33 发布