• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
arunkumar subramanian
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Duplicates removed. Thanks.
 
Santhosh Kumar
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic