For the Hikari connection pool configuration, we enable it by using spring.datasource.type and assigning it fully qualified name of the connection pool implementation in application.properties file as following.
spring.datasource.type = com.zaxxer.hikari.HikariDataSource
If we are using Spring Boot 2.0 and onwards, Spring Boot selects HikariDataSource by default and we need not to configure above line. Now to configure Hikari specific connection pool settings, Spring Boot provides spring.datasource.hikari.* prefix to be used in application.properties file. We will discuss here some frequently used configurations.
connectionTimeout is the maximum number of milliseconds that a client will wait for a connection from connection pool. We need to configure it as following.
minimumIdle is the minimum number of idle connections that is maintained by HikariCP in connection pool. It is configured as following.
maximumPoolSize configures the maximum pool size. It is configured as following.
idleTimeout is the maximum amount of time in milliseconds that a connection is allowed to sit idle in connection pool. It is configured as following.
maxLifetime is the maximum life time in milliseconds of a connection in pool after it is closed. It is configured as following.
An in-use connection will never be retired, only when it is closed will it then be removed after maximum lifetime.
autoCommit configures the default auto-commit behaviour of connections returned from pool. Default value is true.