Discussion:
Logging SQLException
Richard Rodseth
2014-03-31 17:01:14 UTC
Permalink
I have some code which is run asynchronously and catches and logs all
exceptions (by design).

Scenario: The cause chain is:
HibernateJdbcException, GenericJDBCException, SQLException,
BatchUpdateExceptin, BatchUpdateException... ad infinitum

The actual helpful information (a constraint violation) is a PSQLException
in the "next" field of the SQLException.

The log4j output says "Call getNextException to see the cause."

What's an appropriate way to get better logging?

The answer to this SO question seems to suggest no custom code is needed,
but my config seems pretty close:

http://stackoverflow.com/questions/15848359/call-getnextexception-to-see-the-cause-how-to-make-hibernate-jpa-show-the-db

Thoughts? Leave this to the db server log? Traverse the "cause" links
looking for SQLExceptions"?

Loading...