user10252811
user10252811

Reputation: 1

Issue in connection pool startup with hikaricp, jdbctemplate, spring-boot

I am using hikari with spring jdbctemplate in spring boot application. My database connection pool is not starting up after application startup. The connection pool is started only after first call to DB, which results into my first service call. Any suggestion how to initialize connection pool on boot application start up..?

Upvotes: 0

Views: 2599

Answers (2)

user10252811
user10252811

Reputation: 1

Thanks Everyone, i got it fixed Inside my initDatasource method -
first - i created HikariConfig hikariDSObject = new HikariConfig(); then i set all properties At last - i pass hikariDSObject in to HikariDataSource object.

it helps to initialize connection pool at startup

Upvotes: 0

CodeScale
CodeScale

Reputation: 3334

Lazy-init property of JdbcTemplate is set by default to true. So only the first access to it will setup your connection pool.

You can override this behavior in this way :

@Bean public JdbcTemplate jdbcTemplate(DataSource dataSource) { return new JdbcTemplate(dataSource, false); }

Upvotes: 5

Related Questions