0

The HikariCP documentation says:

connectionTimeout: This property controls the maximum number of milliseconds that a client will wait for a connection from the pool. If this time is exceeded without a connection becoming available, a SQLException will be thrown.

Through testing, I see that SQLTransientConnectionException is thrown in this case.

If my pool is exhausted, I get this exception. If my database host is disconnected from the network, I get this exception. If my database instance service is stopped, I get this exception.

The problem is that whatever the reason, the pool will always throw this exception with the same message.

This way I can't inform the users what is going on. If the pool is really exhausted (a normal thing under heavy load) the user should be informed and asked to try again later.

But if my database server is down, It's a different story, and the user should be informed accordingly.

Gustavo
  • 1,332
  • 2
  • 16
  • 39

1 Answers1

0

check yourException.getNextException() or yourException.getCause(), if it is not null that usually means network/database problem.

Note: Hikaricp does not retain this exception. getNextException()/getCause() may be null for very next call to getConnection() that fails.

Reported this at https://github.com/brettwooldridge/HikariCP/issues/719 and good thing is Brett did changes immediately.

Nitin
  • 1,582
  • 11
  • 12
  • He changed one thing but not the other. Is this enough? – Gustavo Sep 14 '16 at 17:16
  • with that change you should be able to progress. please report 'on issue 719' if you face timeout exception with next exception as anything but connection creation failure I hope this is acceptable answer – Nitin Sep 19 '16 at 12:56