public void batchUpdateExec(String sqlId, List<Object> param) throws DaoException {
if (sqlId != null && sqlId.length() > 0) {
if (param != null && param.size() > 0) {
try {
this.getSqlMapClient().startBatch();
for (int i = 0; i < param.size(); i++) {
this.getSqlMapClient().update(sqlId, param.get(i));
}
this.getSqlMapClient().executeBatch();
} catch (SQLException e) {
throw new DaoException(e);
}
}
}
}
if (sqlId != null && sqlId.length() > 0) {
if (param != null && param.size() > 0) {
try {
this.getSqlMapClient().startBatch();
for (int i = 0; i < param.size(); i++) {
this.getSqlMapClient().update(sqlId, param.get(i));
}
this.getSqlMapClient().executeBatch();
} catch (SQLException e) {
throw new DaoException(e);
}
}
}
}
本文介绍了一种批量更新执行的方法,该方法通过遍历参数列表并逐一执行更新操作来实现数据库记录的批量更新。此方法首先检查SQL标识符和参数列表是否有效,然后使用SqlMapClient启动批处理过程,接着遍历参数列表执行更新操作,并最终执行批处理以完成所有更新。
711

被折叠的 条评论
为什么被折叠?



