aspose 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
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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: 32644
    
    4
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Statement.ExecuteBatch - How to get the number of sucess / failure results.
 
Similar Threads
Beginner Struts Problem (Solved)
n in System.exit(n)
Incorrect value of long calculation?
What is the difference between executeUpdate and execute?
How to use Assertions in Java