`
jin8000608172
  • 浏览: 136061 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

JDBC分批更新

阅读更多
@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;
	}
分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics