Reputation: 739
Using connection pools such as Hikari or Oracle UCP, you can set pool size (init size, idle size, max size) and timeouts (idle/inactive connection timeout).
In hikari, you can configure keepaliveTime
(combined with long idle tiemout / max life time) to prevent firewall killing idle TCP connections (SQLRecoverableException: Closed Connection
)...
But in Oracle UCP, I did not find option to enable connection "keepalive". So there might be option to set it on jdbc driver level - oracle.net.keepAlive; oracle.net.TCP_KEEPIDLE; oracle.net.TCP_KEEPINTERVAL; oracle.net.TCP_KEEPCOUNT;
Question:
If I enable keepalive on JDBC driver, what happens to pool's idleTimeout
when pool size is bigger than minimumIdle
?
Would the pool drop such connection as "idle" or would it consider "alive" because of keepalive packets and keep it opened?
Thanks
Upvotes: 0
Views: 997
Reputation: 739
Based on answers, I have decided not to interfere with ojdbc settings and set ucp to validateConnectionOnBorrow=true
, secondsToTrustIdleConnection=1800
to achieve detection of broken connections (because of missing keepalive option in ucp)
Upvotes: 0
Reputation: 46
The correct prefix for UCP properties in Spring Boot is spring.datasource.oracleucp (not just ucp as a previous answer)
Upvotes: 1
Reputation: 300
You can pass the JDBC driver properties to UCP using setConnectionProperties() API like below.
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
Properties props = new Properties();
props.setProperty("oracle.net.keepAlive", "true");
pds.setConnectionProperties(props);
The driver keepAlive settings are transparent to UCP pool, it will close an idle connection if it is inactive from x seconds where x is configured inactive connection timeout on ucp pool.
Upvotes: 0
Reputation: 1
It seems oracleUCP gives an option for you to set keep alive time.
spring.datasource.ucp.time-to-live-connection-timeout
And in general, I don't think it is a good idea to mess with connection settings on the driver level because it could create conflicts!
Upvotes: 0