File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes How to deal with single Erros IN batch updates in JDBC applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to deal with single Erros IN batch updates in JDBC applications " Watch "How to deal with single Erros IN batch updates in JDBC applications " New topic
Author

How to deal with single Erros IN batch updates in JDBC applications

Paulo Cesar Dias Lima
Greenhorn

Joined: Jul 06, 2010
Posts: 12
I need to process only erros commands in my batch updates according
some numbers of tries.

I'm using PreparedStatement and addBatch to compose batchs commands.

After executeBatch() do executes and receiving results in int[].

Instead of catch BatchUpdateException for the batch commands how to catch only the single error statements ?

Thanks,

Paulo Lima.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Paulo Cesar Dias Lima wrote:Instead of catch BatchUpdateException for the batch commands how to catch only the single error statements ?

Run them one at a time? The batch update is integrated. I don't think you can tease it apart like that.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Paulo Cesar Dias Lima
Greenhorn

Joined: Jul 06, 2010
Posts: 12
Jeanne, correct I runned them once a time.

I agree that batch update is integrated so no way to catch individually commands error.

I'm trying to change my Persistence Tier to instead of use JDBC refactory to Stored Procedure that will result the number of rows on Insert/Update/Delete (CRUD) and also using a Queue process like Oracle Advanced Queuing (AQ) to notifies Erros to subscribers Java process.

I have to process a huge amount off request and very short ansewers time!

What do you think about this approach ?

Bill, do you think that using Queuing to catch/notify Huge amount of SQL commands it's a good option ?

I'm not sure if there is a SQL Patterns indicated to this scenario.

Thanks!

Paulo Lima.




Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Paulo,
A sotred procedure cuts down on the netowrk traffic so it will help some.

I don't see how a queue helps you though. Once you introduce the queue, you are no longer updating in a single transaction. And if you don't need a single transaction, that opens the door to other batching techniques - like threading.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to deal with single Erros IN batch updates in JDBC applications