• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Duplicates removed. Thanks.
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic