目前我们的代码使用 JdbcTemplate 的 batchUpdate 方法进行批量插入。
我的问题是,如果其中一个更新出现任何异常,如何处理它(假设只是添加日志)并继续执行下一个更新 sql 语句?
还有 JdbcTemplate 的 batchUpdate() 方法如何处理异常?
片段在这里。
/**
* Saves the list of <code>Item</code> objects to the database in a batch mode
*
* @param objects
* list of objects to save in a batch mode
*/
public void save(final List<Item> listOfItems) {
for (List<Debit> list : listOfItems) {
getJdbcTemplate().batchUpdate(insertItem, new ItemBatchPreparedStatementSetter(list));
}
}