Search code examples
javaspring-bootjdbcquery-timeout

Troubles setting up query time-out connection in spring application


I'm having issues setting up the query time out of my application. I'm using spring-boot, we implemented a Jdbc template to handle the connections (connections pool, Hikari, disabled). I've tried setting up the query time-out connection in my DataSource configuration by:

jdbcTemplate.setQueryTimeout(10);

This didn't work although I realized that the set has been done when I debugged the application. It seems to that the query time-out is disabled because I used a SLEEP call in my query waiting around 5 minutes and I did not get a query time-out exception. I was thinking maybe on some DB2 driver configuration property overriding my connection configuration.


Solution

  • The queryTimeout setting is not supported by the DB2 driver, https://www.ibm.com/support/pages/how-configure-query-timeout-data-server-driver-jdbc.

    Set the DB2 connection property blockingReadConnectionTimeout to timeout.