BatchUpdateException:批处理不会终止 [英] BatchUpdateException: the batch will not terminate
问题描述
在一个循环中,我使用一个 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:批处理不会终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!