Reputation: 289
We have e a small batch project with spring boot and spring batch.
We are using a JdbcBatchItemWriter
with a db2 database. However, when an error occurs, we got the following error message:
Caused by: com.ibm.db2.jcc.am.BatchUpdateException: [jcc][t4][102][10040][3.63.123] Batch failure. The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements. ERRORCODE=-4229, SQLSTATE=null
Unfortunately, to have a clear error message, I need spring to call the getNextException()
to have details about the precise exception. However, I have checked the code of the class SQLErrorCodeSQLExceptionTranslator
and it doesn't look like Spring offer some functionalities for that.
Has anyone found a solution for this problem without rewriting the class SQLErrorCodeSQLExceptionTranslator
?
Upvotes: 1
Views: 2946
Reputation: 3203
This can be handled by checking the list of Exceptions returned by: getAllFailureExceptions() , after jobLauncher.run() ends.
List<Throwable> exceptions = execution.getAllFailureExceptions();
for (Throwable throwable : exceptions) {
//code to handle nested exceptions
}
Upvotes: 1