BatchUpdateException:批处理不会终止

编程入门 行业动态 更新时间:2024-10-13 22:20:01
本文介绍了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:批处理不会终止

本文发布于:2023-10-28 04:38:25,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批处理   BatchUpdateException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!