I was reading up on tuning JDBC connection pool configurations and under the Timeout Settings >> Idle Timeout section, it reads:
For best performance, set Idle Timeout to zero (0) seconds, so that idle connections will not be removed. This ensures that there is normally no penalty in creating new connections and disables the idle monitor thread. However, there is a risk that the database server will reset a connection that is unused for too long.
This last sentence is disconcerting. On Tomcat, you can specify a JDBC connection as a JNDI lookup from inside context.xml
. I assume that the Idle Timeout field in the link above correspond's to Tomcat's (DBCP's) maxIdle
property.
So I ask: what happens if I set maxIdle
to 0, which tells DBCP not to remove idle connections, but then the server hangs up on (or resets) the idle connection? Is there a specific exception that gets called? Will the app just hang? How can I mitigate such problems but still keep maxIdle
at 0?