O'Reilly logo

Java 11 Cookbook by Mohamed Sanaulla, Nick Samoylov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

There are several ways to configure the Hikari connection pool. All of them are based on the usage of the javax.sql.DataSource interface:

  1. The most obvious and straightforward method is to set the pool properties on the DataSource object directly: 
HikariDataSource ds = new HikariDataSource();ds.setPoolName("cookpool");ds.setDriverClassName("org.postgresql.Driver");ds.setJdbcUrl("jdbc:postgresql://localhost/cookbook");ds.setUsername( "cook");//ds.setPassword("123Secret");ds.setMaximumPoolSize(10);ds.setMinimumIdle(2);ds.addDataSourceProperty("cachePrepStmts", Boolean.TRUE);ds.addDataSourceProperty("prepStmtCacheSize", 256);ds.addDataSourceProperty("prepStmtCacheSqlLimit", 2048);ds.addDataSourceProperty("useServerPrepStmts" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required