I am using the following typesafe configuration in application.conf for Slick 3.0. HikariCP is the default connection pool of Slick 3.0. I set the poolName as "primaryPool":
slick.dbs.primary= {
driver="com.typesafe.slick.driver.ms.SQLServerDriver$"
db {
url = "DB URL"
driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
user = "myUser"
password = "myPassword"
poolName="primaryPool"
}
}
From the HikariCP log, I saw Before cleanup pool stats db (total=21, inUse=0, avail=21, waiting=0)
The default connection pool name "db" is used but not what I expected primaryPool. I suspect the configuration format is not correct.
So my question is how to configure poolName in application.conf using Typesafe configuration?
Note: Because I will have several connection pools in my application, I hope particular pool name is logged to distinguish different pool.
I find a workaround by setting poolName in my own code:
val dbConfig = dbConfigProvider.get[JdbcProfile]
val poolName = dbConfig.config.getConfig("db").getString("poolName")
dbConfig .db.source.asInstanceOf[HikariCPJdbcDataSource].ds.setPoolName(poolName)
It is not a good solution since I hard code HikariCPJdbcDataSource, but it can meet my requirement at least.
Still hope get the help how to configure poolName correctly in the application.conf.