HikariCP Configuration in Spring Boot
Fast recall
Quick revision
Core answer
Whether you know HikariCP is the standard pool and its key settings.
Over-tuning or setting an unnecessarily huge maximum-pool-size.
Name the core settings and note HikariCP's defaults are good — change them deliberately.
Interview-ready guide
Interview answer
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.connection-timeout=2s
spring.datasource.hikari.max-lifetime=25mThese are example values, not recommendations. Boot binds them to HikariConfig. It cannot know the database's concurrent capacity, replica count, query latency, or service SLO, so the team must load-test and budget connections across instances.
HikariCP Configuration in Spring Boot
Direct Answer
HikariCP is Spring Boot's preferred/default JDBC pool when it is available and no higher-priority/user DataSource replaces it. Common settings include maximumPoolSize, connectionTimeout, maxLifetime, keepaliveTime, and minimumIdle. idleTimeout only retires surplus idle connections when minimumIdle is below maximumPoolSize. Defaults are sensible starting points, not automatic workload tuning.
Code Example
# application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/shop
spring.datasource.username=app
spring.datasource.password=secret
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.idle-timeout=600000
// Or in plain code without Spring:
HikariConfig cfg = new HikariConfig();
cfg.setJdbcUrl("jdbc:postgresql://localhost:5432/shop");
cfg.setUsername("app"); cfg.setPassword("secret");
cfg.setMaximumPoolSize(10);
DataSource ds = new HikariDataSource(cfg);
Common Mistakes & Pitfalls
- Huge
maximum-pool-size: more isn't better — it overloads the DB; size to real concurrency. - Over-tuning defaults: HikariCP's defaults are good; change with a reason.
- Ignoring
connection-timeout: too low causes spurious timeouts under load. - Adding another pool: HikariCP is already the Spring Boot default.
Check your understanding
Answer these without looking back at the article.
- What is connection pooling and why is it critical for production Java applications?
- What happens when all connections in a pool are in use?
- What is a connection leak in JDBC and how do you prevent it?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.