Issue
I'm using SpringBoot (v2.3.0.RELEASE), JPA and Hibernate (with a MySQL database). I need to try to improve, in general, the performances.
It's not completely clear for me if, into the default configuration, is already there a Database Connection Pool.
I didn't add any specific dependencies into my pom about a connection pool but when I try to run my service I read:
2021-07-01 13:53:04.065 INFO HikariDataSource-getConnection():110 - [ HikariPool-1 - Starting... ]
2021-07-01 13:53:04.499 INFO HikariDataSource-getConnection():123 - [ HikariPool-1 - Start completed. ]
can you give me some info about this?
Do I need to configure (adding the dependency also) a connection pool manually?
Solution
Hikari is the default DataSource implementation with Spring Boot 2. This means we need not add explicit dependency in the pom.xml. The spring-boot-starter-jdbc and spring-boot-starter-data-jpa resolve it by default. To sum up, you require no other steps with Spring Boot 2.
Link for Documentation : Spring Documentation for Connection pools
Although you modify the default properties of HikariCP
spring.datasource.hikari.connection-timeout = 20000 #maximum number of milliseconds that a client will wait for a connection
spring.datasource.hikari.minimum-idle= 10 #minimum number of idle connections maintained by HikariCP in a connection pool
spring.datasource.hikari.maximum-pool-size= 10 #maximum pool size
spring.datasource.hikari.idle-timeout=10000 #maximum idle time for connection
spring.datasource.hikari.max-lifetime= 1000 # maximum lifetime in milliseconds of a connection in the pool after it is closed.
spring.datasource.hikari.auto-commit =true #default auto-commit behavior.
Answered By - Tris
Answer Checked By - Robin (JavaFixing Admin)