mysqlscalahikaricpslick-3.0

How to Set config params in Slick-HikariCP


I am using Slick and Mysql. Getting the Error:

Failed to validate connection com.mysql.jdbc.JDBC4Connection@58e7cfcd (No operations allowed after connection closed.). Possibly consider using a shorter maxLifetime value."

I understand the issue but don't know how to set maxLifetime in slick on config. Here is my config:

mysqldb {
    driver = "com.mysql.cj.jdbc.Driver"
    url = "jdbc:mysql://localhost:3306"
    user = root
    password = root
    connectionTimeout = 10000
    queueSize = 50000
    minConnections = 20
    maxConnections = 40
    numThreads = 40
}

Any help would be appreciated.


Solution

  • you can set under db config:

    mysqldb {
        driver = "com.mysql.cj.jdbc.Driver"
        url = "jdbc:mysql://localhost:3306"
        user = root
        password = root
        connectionTimeout = 10000
        queueSize = 50000
        minConnections = 20
        maxConnections = 40
        numThreads = 40
        idleTimeout = 85000 // should be less than maxLifetime
        maxLifetime = 90000 //time is in millsecods and should be less than database wait_timeout
    }