Mohd
Mohd

Reputation: 191

HikariCP - add properties to JDBC url

For regular JDBC connection you can add the properties to the DriverManager:

url = "jdbc:postgresql://host:port/db?user=user&password=pass";

Properties props = new Properties();

DriverManager.getConnection(url,props);

for HikariCP it has hikariConfig.setJdbcUrl(url);

How to add properties for the JDBC connection (not the HikariCP properties)?

Upvotes: 2

Views: 6358

Answers (1)

Ori Marko
Ori Marko

Reputation: 58822

See Hikari's initialization, you can add property by using config.addDataSourceProperty method:

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");
config.setUsername("bart");
config.setPassword("51mp50n");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

Upvotes: 3

Related Questions