I have code to do a batch insert into a SqlServer or Oracle table. How can I tell JDBC to
A) Keep going if one of the insert statements fails
B) Inform me which one had the issue
sql.withBatch("""Insert Into ${job.table}($columnNames)Values(${values})""") { stmt ->
data.each{ Map<String, String> row ->
stmt.addBatch(newMap)
}
}
Currently, if one of the rows has an issue, it successfully inserts everything that came before it, and stops inserting rows afterwards. And it'll tell me the error message, but not what data caused the error. A solution in either java or groovy is fine.
My question is not the same as the other one. His issue is specifically around avoiding inserting duplicates. I need to prevent the batch from failing because an insert failed for any reason. If the solution turns out to be sql-related, I'd need both Tsql and PL/SQL solutions (the other post is specific to postgresql)