How to handle JDBC BatchUpdateException - TechRepublic
General discussion
June 10, 2003 at 10:08 PM
dmitry

How to handle JDBC BatchUpdateException

by dmitry . Updated 21 years, 11 months ago

Please help –

I use batch insert for inserting records into the database. Sometimes, when calling statement.executeBatch(), the database throws BatchUpdateException due to a unique constraint. I need to find out which record violated the constraint and reject it. I have tried calling ex.getUpdateCounts(), but all elements in the array have the same value (-3). Is it how the driver supposed to work? Is there another way to figure out which record(s) in the batch violated the unique constraint?

This discussion is locked

All Comments