Reputation: 67
I surprisingly discovered that liquibase creates his own connection pool with default values and therefore holds 10 connections to db. It doesn't use connection pool configured from application.properties. So, I have a couple of questions:
Upvotes: 1
Views: 1598
Reputation: 6391
The linked question has indeed a correct answer. But obviously, 10 connections are taken from the default settings of Hikari Pool (it is the default db connection pool starting from Spring Boot 2.0).
So, here is the modified version of the same configuration but with Hikari instead of tomcat-jdbc:
@LiquibaseDataSource
@Bean
public DataSource liquibaseDataSource() {
DataSource ds = DataSourceBuilder.create()
.username(liquibaseDataSourceProperties.getUser())
.password(liquibaseDataSourceProperties.getPassword())
.url(liquibaseDataSourceProperties.getUrl())
.driverClassName(liquibaseDataSourceProperties.getDriver())
.build();
if (ds instanceof HikariDataSource) {
((HikariDataSource) ds).setMaximumPoolSize(2); //10 by default
}
return ds;
}
Upvotes: 1