6

I was looking into HikariCP for using it in one of my projects. The statement cache section of the project page in github says that it doesn't support prepared statement cache at the connection pool level.

But the initialization section has the below code snippet

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");

HikariDataSource ds = new HikariDataSource(config);

and it sets prepared statement cache config. Is it being configured for the connection pool or the driver below? Also what are the properties supported by addDataSourceProperty method?

Ori Marko
  • 56,308
  • 23
  • 131
  • 233

1 Answers1

1

The datasource is configured and used by MySql in your case.

Basically you can send relevant properties to your implementation.

For example for oracle you can send

dataSource.addDataSourceProperty("oracle.jdbc.defaultNChar", "true");

And this property will be used in oracle implementation

HikariCP save it in properties and copy it to driver Properties and use it on connect :

for (Entry<Object, Object> entry : properties.entrySet()) {
         driverProperties.setProperty(entry.getKey().toString(), entry.getValue().toString());
      }
....
driver.connect(jdbcUrl, driverProperties);
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
  • Thanks for your answer. Now I understand that the caching is for the driver and we can set the driver properties using addDataSourceProperty. But I couldn't find the data source property to be set for enabling cache in oracle driver (as you said the sample code snippet is for MySQL). – sivaguru perumal Aug 09 '17 at 07:14
  • See https://stackoverflow.com/questions/12167108/using-oracle-jdbc-driver-implicit-caching-feature – Ori Marko Aug 09 '17 at 07:27