ScriptsJul 13, 2026·3 min read

HikariCP — Lightning-Fast JDBC Connection Pool for Java

HikariCP is a high-performance JDBC connection pool library for Java applications, known for minimal overhead and battle-tested reliability in production environments.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 98/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Skill
Install
Single
Trust
Trust: Established
Entrypoint
HikariCP Overview
Direct install command
npx -y tokrepo@latest install df02e35d-7eb8-11f1-9bc6-00163e2b0d79 --target codex

Run after dry-run confirms the install plan.

Introduction

HikariCP is a production-grade JDBC connection pooling library for Java. It focuses on correctness, simplicity, and raw speed, consistently outperforming alternatives like Apache DBCP2 and C3P0 in benchmarks. It is the default connection pool in Spring Boot.

What HikariCP Does

  • Manages reusable JDBC connections to avoid per-query open/close overhead
  • Validates connections before handing them out, preventing stale-connection errors
  • Provides configurable pool sizing with minimum idle and maximum pool limits
  • Supports connection leak detection with configurable timeout alerts
  • Integrates with JMX and Micrometer for runtime pool metrics

Architecture Overview

HikariCP uses a custom lock-free ConcurrentBag collection for pooled connections, bypassing traditional blocking queues. It avoids object allocation on the hot path and uses bytecode-level optimizations via Javassist to generate fast proxy classes for Connection, Statement, and ResultSet objects. A background housekeeper thread handles idle connection retirement and keepalive queries.

Self-Hosting & Configuration

  • Add the HikariCP Maven or Gradle dependency to your project
  • Configure via HikariConfig object or a hikari.properties file
  • Set minimumIdle, maximumPoolSize, connectionTimeout, and idleTimeout
  • Enable leak detection with leakDetectionThreshold (recommended: 2000ms in dev)
  • Use connectionTestQuery only for drivers that lack JDBC4 isValid() support

Key Features

  • Sub-microsecond getConnection() latency under contention
  • Automatic connection validation without per-query overhead via JDBC4 isValid
  • Built-in connection leak detection with stack trace logging
  • JMX and Micrometer metrics for pool utilization and wait times
  • Minimal footprint: SLF4J as the only dependency, ~130KB JAR

Comparison with Similar Tools

  • Apache DBCP2 — more configuration knobs but higher latency and memory use
  • C3P0 — mature but complex config and slower failure recovery
  • Tomcat JDBC Pool — tied to Tomcat ecosystem; HikariCP runs anywhere
  • Vibur DBCP — similar goals but smaller community and less adoption
  • Agroal — Quarkus default; HikariCP is the Spring Boot default

FAQ

Q: Why is HikariCP the default in Spring Boot? A: Its low latency, small footprint, and reliable connection validation make it a safe default for most applications.

Q: How do I size the pool? A: A common formula is connections = (core_count * 2) + effective_spindle_count. For most apps with SSDs, 10-20 connections per node is a good start.

Q: Does it support read/write splitting? A: No. HikariCP is a connection pool, not a proxy. Use application-level routing or a proxy like ProxySQL.

Q: Which databases does it support? A: Any database with a JDBC driver: PostgreSQL, MySQL, Oracle, SQL Server, H2, and more.

Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets