title: does jdbcConnection have ExceptionListener support, similar to jmsConnection?
body: <p>We use XA/distributed transaction, and I'm trying to notify/update global transaction status, should a participating xaResource-branch throw an exception. </p>
  
  <p>A good example can be found in JMS <code>Connection#setExceptionListener()</code>, (ref.<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Connection.html#setExceptionListener-javax.jms.ExceptionListener-" rel="nofollow noreferrer">link</a>), which offers notification hook in the <code>ExceptionListener</code>. I'm looking for something similar in JDBC specification, but I haven't been able to find any. </p>
  
  <p>XA Transaction processing is single-threaded in our application, and a given global transaction can touch multiple xaResource-branches. Assuming UOW happens in the order of <code>rA</code>, <code>rB</code> and <code>rC</code>, it happens we might have a slow query running on <code>rB</code>, causing <code>rA</code> timeout before <code>rC</code> starts. Because of the single threaded nature (and the limitation of the TM we use), <code>rC</code> still proceeds while the fate of the global transaction has already been determined (to rollback). We are trying to notify the global transaction of the fact <code>rA</code> has already been rolled back so that <code>rC</code> can be skipped. </p>
  
  <p>If the JDBC specification doesn't offer something similar to JMS's ExceptionListener, one option I can think of would be using async thread(s) to test the JDBC connection with a certain frequency. The closest example I've found so far is described in this PostgreSQL documentation (ref.<a href="https://jdbc.postgresql.org/documentation/head/listennotify.html" rel="nofollow noreferrer">link</a>), which uses asynchronous thread(s) to test/poll JDBC connection. It probably satisfies my need, but wondering if there's any other option I missed in the JDBC specification.</p>