BatchUpdateException:批处理不会终止 [英] BatchUpdateException: the batch will not terminate

查看:461
本文介绍了BatchUpdateException:批处理不会终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序处理一个非常大的文件并将数据发送到oracle数据库(使用Java 6,oracle 9)。



在一个循环中,我使用一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆