On 19/08/14 16:26, "Christopher Schultz" <ch...@christopherschultz.net> wrote: > >On 8/18/14, 1:05 PM, Wes Clark wrote: >> One of the primary conditions for which we want to mark the >> connection for death is when a rollback fails with an exception. >> An example of this kind of error is a network error. > >Won't this happen automatically? If the network connection dies, the >server should auto-rollback the transaction. The JDBC connection will >fail due to the same reason and the pool will re-establish a new >Connection. Are you sure you have to manage this yourself?
For the pool to re-establish a new connection you have to set testOnBorrow=3Dtrue, otherwise you have to wait until the next time the PoolCleaner kicks in (provided you have testOnIdle=true). Wes¹ proposition speeds up the detection of the dead connection without requiring a validation on borrow. > >> We do this with: >> >> PooledConnection pooledConnection = >> conn.unwrap(PooledConnection.class); >> pooledConnection.setDiscarded(true); >> >> I think I'll modify my code so that if an exception is thrown, >> instead of unconditionally evicting the connection from the pool, >> run the validation query right then and only evict if it fails. > >This won't catch intermittent network errors, which seems like the >only really valid use case for you. We also faced some weird jdbc drivers that forced us to drop a connection after some specific exceptions have occurred. If not, we got strange behaviour with some queries but not all (and of course the validation query was ok :-( Here also we followed an approach similar to Wes=B9 proposal. /Bertrand --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org