The Oracle JDBC driver throws a BatchUpdateException if an error occurs in the middle of the batch. Using NamedParameterJdbcDaoSupport to insert data as below
getJdbcTemplate().batchUpdate(query, dataList, 1000,
new ParameterizedPreparedStatementSetter<MyObject>() {
@Override
public void setValues(final PreparedStatement ps, final MyObject bucket) throws SQLException {
ps.setString(1, bucket.getInit());
ps.setString(2, bucket.getNbr());
}
});
I'm running into BatchUpdateException because of unique key constraint, we are processing millions of records so we can't go to database to check unique key.
Is there anyway that batch insert won't fails if one record failed.