• 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

Handle BatchUpdateException

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

I am using PreparedStatment to execute a set of inserts in the database.As i need to insert some 200 odd records i am using addBatch and executeBatch() methods to make all the inserts together.

My problem is a particular set of entries is causing problems during insert and my code is throwing a BatchUpdateException.

Now is there a way to find out which set of entries has caused the exception or if that is not possible is there a way in which i can handle this Exception and cause the rest of the batch of inserts to go through leaving the problematic set of inserts?

Please help

Thanks
Hemant
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get some info with this method
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/BatchUpdateException.html#getUpdateCounts()

I would probably NOT run the rest of the statements if something fails. But if they are unrelated and not transaction-oriented, you could.
 
reply
    Bookmark Topic Watch Topic
  • New Topic