4

I am using a desktop application with PostgreSQL database server. When I am not using application for 10 to 20 minutes continuously, the database connection is dropped. And I am using PostgresqlJDBC for database connection.

Please help me on this to database connection time out.

Thanks.

1
  • I know its a desktop-app but beside this: using Tomcats JNDI datasources its the XML-Parameter <Resource ... maxWait="1" ... > for connection. I also use a Map<Session,Exception> to log where sessions has never closed. Commented Feb 17, 2015 at 7:06

1 Answer 1

4

Sounds like you are connected via a stateful connection tracking router/firewall that has a short connection tracking timeout. Sounds like you need to enable keepalives.

Take a look at the tcp_keepalives_interval and tcp_keepalives_idle parameters.

You can also request keepalives client-side in the JDBC driver; see the pgJDBC docs.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I will look into pgJDBC docs. Can you please tell me the (best and optimized) values for both the parameters?
If there was a single value that was right for everybody, it would not be a parameter. It depends on your environment - how often the timeouts occur, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.