(If the answer differs between Tomcat 7 and Tomcat 8, please note that.)

When a SQL exception occurs, often the database connection will be broken and 
should be evicted from the pool.  In our code, we call this "marking the 
connection for death".  We do this because we don't want to set the 
"testOnReturn" attribute to true to minimize the load on the database server.  
We set "testOnIdle" which will eventually find and evict stale connections, but 
maybe not fast enough for a bad connection which is returned to the pool.

My question is whether the "test on return" is done on the same thread as the 
user, or on a different thread that belongs to the connection pool.  If the 
latter, we wouldn't have to catch the fact that SQL exception has occurred and 
make sure the connection is evicted from the pool, and maybe would be okay with 
the extra load on the database server as long as the user time is not affected.

Reply via email to