在一个循环中,我使用一个 PreparedStatement ps 并创建所有使用 ps.addBatch()。
我有一种情况,一个 BatchUpdateException bue 是在 ps.executeBatch()中的某个地方抛出。在这一点上,批处理停止执行。
我希望批处理执行继续,以便我可以在方法中检查失败的更新 processUpdateCounts(bue.getUpdateCounts())。
关于BatchUpdateException类的javadoc说:
批量更新中的命令无法正常执行,并抛出 BatchUpdateException, 驱动程序可能会可能不会继续到处理批中的剩余命令。
有没有执行延续的方式,还是需要修改程序,以便单独执行该语句?
解决方案刚刚找到此链接: JDBC批次更新问题
显然,它表示有
NO WAY WITH ORACLE BATCH JDBC 在第一次失败后继续
(抱歉找不到更好找到上面的链接)。
I have an application which processes a very large file and sends data to an oracle database (using Java 6, oracle 9).
In a loop, I use a PreparedStatement ps and create all SQL statements generated with ps.addBatch().
I have a situation where a BatchUpdateException bue is thrown somewhere during the ps.executeBatch(). At that point, the batch stops to be executed.
I'd like the batch execution to continue, so that I can then check on failed updates in a method processUpdateCounts(bue.getUpdateCounts()).
The javadoc about class BatchUpdateException says:
After a command in a batch update fails to execute properly and a BatchUpdateException is thrown, the driver may or may not continue to process the remaining commands in the batch.
Is there a way to enforce continuation or do I need to alter my program so that it will execute the statement individually?
解决方案Just found this link: JDBC Batch Update Problem
Apparently, it says there there is
NO WAY WITH ORACLE BATCH JDBC to proceed after first failure,
thus I am resorting to sending the inserts one by one. Thank you
(sorry for not looking better to find the link above before).
更多推荐
BatchUpdateException:批处理不会终止
发布评论