Web Development

General discussion


How to handle JDBC BatchUpdateException

By dmitry ·
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 conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Related Discussions

Related Forums