Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HikariCP prepared statement cache

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?

like image 632
sivaguru perumal Avatar asked Nov 08 '22 18:11

sivaguru perumal


1 Answers

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);
like image 184
user7294900 Avatar answered Nov 15 '22 08:11

user7294900