javaoracle-databasejdbctimeoutojdbc

add read timeout for oracle DataSource resource in tomcat


I want to define a socket timeout for each connection created by the connection pool using the oracle.jdbc.ReadTimeout property. How can I configure this in the context below? I am currently using ojdbc6-11.2.0.3.jar and Apache DBCP 2.

    <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"