Oracle connection/query timeout

前端 未结 4 1081
鱼传尺愫
鱼传尺愫 2021-01-18 13:57

Is it possible to specify connection/query timeout for the Oracle database queries? Either on Oracle side or in Oracle\'s JDBC driver (10.2.0.4)? So, that Java client just g

4条回答
  •  醉酒成梦
    2021-01-18 14:38

    Setting oracle.jdbc.ReadTimeout helped to timeout the jdbc calls. I have used it in a production spring boot app by specifying datasource properties as below

    spring.datasource.hikari.connection-timeout=1000
    spring.datasource.hikari.dataSourceProperties=oracle.jdbc.ReadTimeout=2000
    

    Note: Earlier this app was using tomcat connection pool and after setting the above properties for the same, timeouts were happening but the pool was not able to handle the closed connection objects efficiently. Therefore, I switched to hikariCP and got lot better results. I have made a video simulating the slow jdbc calls which compares the results with tomcat and hikari connection pools while using the ReadTimeout property.

提交回复
热议问题