Hello!

When you use JDBC directly, H2 throws BatchUpdateException in case of 
failure, but only after execution of all commands in the batch (other 
drivers may stop after a first failure, but every driver must always 
continue processing or always stop processing). getUpdateCounts() and 
modern getLargeUpdateCounts() methods of this exception return an array 
with update counts or statuses.

For example, attempt to insert values 1, 1, 2, and 1 into a unique column 
throws this exception with [1, -3, 1, -3] result. It means that first and 
third insertions were successful, but second and fourth weren't.

If there were no failures, executeBatch() and modern executeLargeBatch() 
methods return the same array with update counts.

When you use third-party wrappers on top of JDBC you need to check their 
documentation, because their behavior may be different from your 
expectations.

Also you can use a MERGE 
<https://h2database.com/html/commands.html#merge_using> command for 
conditional insertions instead of INSERT to avoid any exceptions here.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/7092b867-c5e5-48de-a261-45c98e5b3c24n%40googlegroups.com.

Reply via email to