The two main config parameters that cover bad connections are test-connection-on-reserve, and test-frequency-seconds.
The first is the primary means for ensuring your applications get good connections. A connection will be tested before
giving it to you and replaced if bad. Test frequency is how often the pool will test currently unreserved connections. This
is usually a secondary concern, but it does help in cases where too-long idle connections may be killed by the DBMS
or firewall etc, and periodic testing keeps them active enough to remain.