Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Hikari Connection Pool Snippet

DZone's Guide to

Hikari Connection Pool Snippet

A solid high-performance JDBC connection pool at last.

· Java Zone
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

DataSource Configuration in Java: 


HikariConfig config = new HikariConfig();
config.setDriverClassName(“org.postgresql.Driver”);
config.setJdbcUrl(postgresqlConfig.getUrl());
config.setUsername(postgresqlConfig.getUser());
config.setPassword(postgresqlConfig.getPassword());
config.setMinimumIdle(postgresqlConfig.getMaxIdle());
config.setMaximumPoolSize(postgresqlConfig.getMaxActive());
config.addDataSourceProperty(“cachePrepStmts”, “true”);
config.addDataSourceProperty(“prepStmtCacheSize”, “250”);
config.addDataSourceProperty(“prepStmtCacheSqlLimit”, “2048”);
return new HikariDataSource(config);


Gradle dependency:


compile ‘com.zaxxer:HikariCP:2.4.1’


Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:
java ,connection pool ,jdbc

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}