Reputation: 47
I want to change Hikari pool size for my custom DataSource, I use Spring boot 2+ version.
I can set dataSource url,dataSource password etc. I wrote values to application.properties file.After that I read these values with environment.getproperty and set dataSource but I donot know same process for pool size:(
Upvotes: 2
Views: 9789
Reputation: 304
I am assuming you custom your dataSource by set your DataSource bean. then you can create custom hikariconfig as follow, remember to replace hard code values below with values in your environment.getproperty:
@Bean
public DataSource getDataSource() {
HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://yourhostname:port/dbname");
config.setDriverClassName("com.mysql.jdbc.Driver");
config.setUsername("dbUsername");
config.setPassword("dbPassword");
config.setMinimumIdle(10);
config.setMaximumPoolSize(10);
config.setConnectionTimeout(1500);
//you can set more config here
return new HikariDataSource(config);
}
Upvotes: 4