0

I have spring boot application using MySQL database. I am using hikari connection pool.

According to this official blog of Hikari https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration, I have to set some properties for performance improvement e.g.

dataSource.prepStmtCacheSize=250
dataSource.prepStmtCacheSqlLimit=2048
dataSource.useServerPrepStmts=true
dataSource.useLocalSessionState=true

But I am not sure how to set these properties without explicitly creating bean of HikariDataSource as mentioned in this link: https://github.com/brettwooldridge/HikariCP/issues/1200

I am aspiring to set these properties directly via spring configuration file (property file or YML file)

Dhruv
  • 10,291
  • 18
  • 77
  • 126
  • See https://stackoverflow.com/questions/23172643/how-to-set-up-datasource-with-spring-for-hikaricp/24500712 – Ori Marko Nov 14 '18 at 14:52

1 Answers1

0

These parameters can be easily configured via a simple configuration.

Just append these property/properties in standard spring datasource -> url property

spring.datasource.url=jdbc:mysql://localhost:3306/databasename?rewriteBatchedStatements=true&useLocalSessionState=true&cachePrepStmts=true&prepStmtCacheSize=250&prepStmtCacheSqlLimit=2048

Similarly, other properties can be appended using & symbol.

Dhruv
  • 10,291
  • 18
  • 77
  • 126