Play+slick+mysql exception


(Mohit Jaggi) #1

Tried the google group but it seems it is deprecated. I am trying to connect to a mysql DB from my play/slick application. Whenever, I hit a REST endpoint that tries to read from DB, I get the following:

play.api.UnexpectedException: Unexpected exception[SQLTransientConnectionException: db - Connection is not available, request timed out after 1005ms.]^M
        at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:186)^M
        at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:124)^M
        at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:82)^M
        at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:185)^M
        at com.typesafe.netty.http.HttpStreamsHandler.channelRead(^M
        at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(^M
Caused by: java.sql.SQLTransientConnectionException: db - Connection is not available, request timed out after 1005ms.^M
        at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(^M
        at com.zaxxer.hikari.pool.HikariPool.getConnection(^M
        at com.zaxxer.hikari.pool.HikariPool.getConnection(^M
        at com.zaxxer.hikari.HikariDataSource.getConnection(^M
        at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:18)^M
        at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:57)^M
        at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:60)^M
        at play.api.db.evolutions.DatabaseEvolutions.databaseEvolutions(EvolutionsApi.scala:132)^M
        at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:110)^M
        at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:125)^M

I am able to connect to the mysql server mysql workbench.

My application conf looks like this:

db {
  # You can declare as many datasources as you want.
  # By convention, the default datasource is named `default`

  default.driver = org.h2.Driver
  default.url = "jdbc:h2:mem:play;DB_CLOSE_DELAY=-1"
  #default.username = sa
  #default.password = ""
  # You can turn on SQL logging for any datasource
slick.dbs.default.driver = "slick.driver.MySQLDriver$"
slick.dbs.default.db.driver = "com.mysql.jdbc.Driver"
slick.dbs.default.db.url = "jdbc:mysql://x.x.x.x:1725/verifyServerCertificate=false&useSSL=true"

# DB credentials
include file("/xxxx/") #has user and password
slick.dbs.default.db.user = ${user}
slick.dbs.default.db.password = ${password}

(Marcos Pereira) #2


Can you confirm the database is accessible from the machine where the application is running? It looks like it is not accessible at all instead of having a problem with credentials.

(Mohit Jaggi) #3

Thanks…it turns out that a max connection limit imposed by the DB was the culprit. But due to the multiple layers of indirection between the application code and the code connecting to the DB (slick->play->hikaricp) it was hard to figure that out.

(Rich Dougherty) #4

Yes it can be confusing. Glad you got it worked out.