Batch inserts with JDBC and Unique constraint

时间:2015-06-25 18:52:17

标签: java sql postgresql jdbc

I have a working method in Java that inserts many rows as a batch. The issue I'm facing is that I have a unique constraint on my table and if there are some rows that are already in the table the method does not insert the ones that do not belong in the database. Instead it throws the following exception java.sql.BatchUpdateException: Batch entry 0 INSERT INTO .... was aborted. Call getNextException to see the cause. Is there anything I can do to make the method insert the ones that are not already in table and not abort like it's doing now?

1 个答案:

答案 0 :(得分:0)

You can handle this stuff through before insert trigger on that table.