javaoracle-databasejdbctimeoutojdbc

How to set timeout for each pooled connection in Apache DBCP 2


I need to configure a socket read timeout for every connection in my Apache DBCP 2 pool using the Oracle JDBC

Environment:

JDBC driver: ojdbc6-11.2.0.3.jar
Connection pool: Apache DBCP 2
App server: Tomcat (JNDI DataSource)

Current context.xml

<Resource name="A/dataSource" auth="Container" type="javax.sql.DataSource"
    maxActive="400" maxTotal="400" maxIdle="50" maxWait="10000" username="..."
    password="..." driverClassName="oracle.jdbc.driver.OracleDriver"
    url="..." autoReconnect="true"
    removeAbandoned="true" logAbandoned="true" removeAbandonedTimeout="60"
    validationQuery="select 1 from dual" >
</Resource>

Solution

  • You can use connectionProperties attribute for that in your context.xml file: connectionProperties="oracle.jdbc.ReadTimeout=5000"