java - Tomcat/DBCP Idle Timeout: What if server hangs up? -


i reading on tuning jdbc connection pool configurations , under timeout settings >> idle timeout section, reads:

for best performance, set idle timeout 0 (0) seconds, idle connections not removed. ensures there no penalty in creating new connections , disables idle monitor thread. however, there risk database server reset connection unused long.

this last sentence disconcerting. on tomcat, can specify jdbc connection jndi lookup inside context.xml. assume idle timeout field in link above correspond's tomcat's (dbcp's) maxidle property.

so ask: happens if set maxidle 0, tells dbcp not remove idle connections, server hangs on (or resets) idle connection? there specific exception gets called? app hang? how can mitigate such problems still keep maxidle @ 0?

with tomcat or dbcp connection pool, mitigate such problems using validation queries, have health of connection checked when connection checked out pool (this validateonborrow property).

with tomcat pool, can instead configure validate idle connections periodically (validatewhileidle, believe) rather having connection checked on every single use of it.


Comments