theGamblerRises theGamblerRises - 3 months ago 26
Java Question

JOOQ : getNextException call?

I am using JOOQ's

batch*
methods. I tried with
batchUpdate
,
batchInsert
methods as well.

Batch batch = create.batchStore(questions);
int[] counts = batch.execute();


Where questions is a list of Generated TableRecords class. I get success while trying to insert data. But I get error while trying to update data.
My query is -


  • How to get JDBC error, since I am getting this exception.

    org.jooq.exception.DataAccessException: SQL [Batch entry 0 insert into ...rest query...] was aborted. Call getNextException to see the cause.

    I don't see
    getNextException
    method in JOOQ's DataAccessException. I am unable to catch either BatchUpdateException of SqlException in order to get further details about exception.


Answer

jOOQ's DataAccessException is an unchecked wrapper for the JDBC SQLException. If you want to get a hold of those, you can access the SQLException as such:

((SQLException) dataAccessException.getCause()).getNextException();