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 Statement.ExecuteBatch - How to get the number of sucess / failure results. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Statement.ExecuteBatch - How to get the number of sucess / failure results." Watch "Statement.ExecuteBatch - How to get the number of sucess / failure results." New topic
Author

Statement.ExecuteBatch - How to get the number of sucess / failure results.

arunkumar subramanian
Ranch Hand

Joined: Jun 10, 2008
Posts: 32
How to get the number of success and failures, If i use executebatch()?

When I use it in a test program and iterate the int[], I get -2 as value in the array even when the table got updated/inserted.

In the sameway If I use executeUpdate(), I get 0 for failure (or no update) and >0 for success (database updated).
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38818
    
  23
Please don't ask what is to all intents and purposes the same question as you asked half an hour previously. Please use the FAQ link above, then go to the "how to ask questions on JavaRanch" link. [edit]Add this FAQ link.[/edit]
[ July 07, 2008: Message edited by: Campbell Ritchie ]
arunkumar subramanian
Ranch Hand

Joined: Jun 10, 2008
Posts: 32
Duplicates removed. Thanks.
Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
You are interpreting the int[] array returned by executeBatch() incorrectly. See the Javadocs for correct interpretation.

To summarize:

>= 0 means, statement executed successfully and value indicates number of rows modified by that statement

-2 means, statement executed successfully but driver couldn't get the number of rows modified by the statement

-3 means, statement failed to execute.

So to emphasize, 0 means successfully executed with zero modifications.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statement.ExecuteBatch - How to get the number of sucess / failure results.