Skip to content

Showcases how the PostgreSQL JDBC driver behaves when either using the socketTimeout connection property or calling java.sql.Statement.setQueryTimeout()

Notifications You must be signed in to change notification settings

sebastiankirsch/postgres-timeout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This scenario illustrates how the PostgreSQL JDBC driver behaves when either using the socketTimeout connection property or calling java.sql.Statement.setQueryTimeout().

When the socketTimeout is reached, the JDBC driver closes the underlying connection; whereas the queryTimeout leaves the connection in a usable state.

This basically forbids setting socketTimeout when connection pooling is used in a liberal fashion, as the pool is not informed that the connection is closed.
With "liberal fashion" I mean (using e.g. the Tomcat JDBC pool, the default of Spring-Boot): you're not explicitly setting either testOnReturn or testOnBorrow along with an validationInterval less than the socketTimeout.

About

Showcases how the PostgreSQL JDBC driver behaves when either using the socketTimeout connection property or calling java.sql.Statement.setQueryTimeout()

Resources

Stars

Watchers

Forks

Languages