java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30006ms. code example

Example: spring Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms

//Your database is not obtaining connection 
//within (30000 milliseconds that is default connectionTimeout property) 
//because of network latency or some of the queries which are taking too 
//long to execute(more than 30000 milliseconds).

//Please try to increase value of property connectionTimeout.

//YML configuration example:

spring:
  datasource:
    hikari:
      minimumIdle: 2
      maximumPoolSize: 20  //increase if you guess that you will have more than 20
      idleTimeout: 120000
      connectionTimeout: 300000
      leakDetectionThreshold: 300000
//Java Config example:

HikariConfig config = new HikariConfig();
        config.setMaximumPoolSize(20);
        config.setConnectionTimeout(300000);
        config.setConnectionTimeout(120000);
        config.setLeakDetectionThreshold(300000);

Tags:

Java Example