If your Java app treats database connections like disposable party favors you will hit trouble. HikariCP gives you a sane JDBC connection pool that actually behaves and does not pretend to be magic. This guide shows how to wire HikariCP up to Microsoft SQL Server and keep the database from staging a revolt.
Short answer: it is fast, light, and predictable. Long answer: HikariCP minimizes overhead when acquiring and releasing JDBC connections and exposes the knobs you need to tune actual throughput. That matters more than creating new connections on demand like it is 1999.
Make sure the runtime has both the Microsoft JDBC driver and HikariCP. For Maven add dependency entries to your pom.xml. For Gradle add implementation lines to your build file.
<!-- Maven examples -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.0.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>12.2.0.jre11</version>
</dependency>
# Gradle example
# implementation 'com.zaxxer:HikariCP:5.0.1'
# implementation 'com.microsoft.sqlserver:mssql-jdbc:12.2.0.jre11'
Use HikariConfig or create a HikariDataSource directly. Point it at the Microsoft DataSource implementation for best compatibility and avoid repeatedly composing long JDBC URLs in code.
// Java example
HikariConfig cfg = new HikariConfig();
cfg.setDataSourceClassName("com.microsoft.sqlserver.jdbc.SQLServerDataSource");
cfg.addDataSourceProperty("user", "yourUser");
cfg.addDataSourceProperty("password", "yourPassword");
cfg.addDataSourceProperty("serverName", "db-host");
cfg.addDataSourceProperty("databaseName", "mydb");
cfg.setMaximumPoolSize(20);
cfg.setConnectionTimeout(30000);
cfg.setIdleTimeout(600000);
HikariDataSource ds = new HikariDataSource(cfg);
Bind the DataSource into your DAOs so they call ds.getConnection() instead of new DriverManager calls. Frameworks such as Spring Boot will accept a HikariDataSource bean and wire the pool automatically. If you wire things manually remember to close the DataSource on shutdown to avoid orphaned sockets.
Spring Boot uses HikariCP by default when it finds the dependency. Typical properties go into application.properties or application.yml and are sane defaults. Override them when your workload needs it.
# application.properties example
spring.datasource.url=jdbc:sqlserver://db-host;databaseName=mydb
spring.datasource.username=yourUser
spring.datasource.password=yourPassword
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.connection-timeout=30000
Expose metrics with Micrometer or JMX so you can see active connections idle connections and waiting threads. HikariCP exposes useful MBeans and Meter bindings that integrate with most observability stacks. Logs often tell the story when acquisition times spike or connections time out.
Steps in one line for those who skim and pretend they read it
Remember the goal is predictable latency and efficient database resource use not heroic connection creation on demand. If the database is the bottleneck you will get better returns from query tuning and indexing than from cranking up the pool size and hoping for the best.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.