Play-Slick unable to connect to database

404 views
Skip to first unread message

Grzegorz Kamola

unread,
Aug 17, 2016, 8:36:15 AM8/17/16
to play-framework
Hi,

I'm close to loose my patience with setting up play-slick to work with mysql. With the first request to the server, I see:

play.api.UnexpectedException: Unexpected exception[SQLTimeoutException: Timeout after 1003ms of waiting for a connection.]
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:170)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
at scala.util.Success.flatMap(Try.scala:231)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
Caused by: java.sql.SQLTimeoutException: Timeout after 1003ms of waiting for a connection.
at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:227)
at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:182)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:93)
at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:12)
at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:57)
at play.api.db.slick.evolutions.internal.DBApiAdapter$DatabaseAdapter.getConnection(DBApiAdapter.scala:60)
at play.api.db.evolutions.DatabaseEvolutions.databaseEvolutions(EvolutionsApi.scala:124)
at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:102)
at play.api.db.evolutions.DatabaseEvolutions.scripts(EvolutionsApi.scala:117)
at play.api.db.evolutions.DefaultEvolutionsApi.scripts(EvolutionsApi.scala:82)
Caused by: java.sql.SQLException: Access denied for user ''@'192.168.99.1' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3847)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3783)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:871)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1665)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1207)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2249)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2280)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2079)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794)

In my application.config I have:

slick.dbs.default.driver = "slick.driver.MySQLDriver$"
slick.dbs.default.db.driver = "com.mysql.jdbc.Driver"
slick.dbs.default.db.url = "jdbc:mysql://192.168.99.100:3306/DB"
slick.dbs.default.db.connectionTestQuery = "select 1"
slick.dbs.default.db.username = "X"
slick.dbs.default.db.password = "Y"

In my build.sbt:

libraryDependencies ++= Seq(
  "com.typesafe.play" %% "play-slick" % "2.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
  evolutions,
  "mysql" % "mysql-connector-java" % "5.1.36")

I managed to make it work with H2 before, so I guess it is only mysql related problem. Note that in the stacktrace, there is error "Access denied for user ''@'192.168.99.1' (using password: YES)", with ip address different from the one in application.config.

I am able to successfully connect to the mysql (running in the docker), using:

mysql -u X -p DB -h 192.168.99.100 and giving password Y. 

I have tried different config options, like:

db.default.driver = com.mysql.jdbc.Driver
db.default.url = "jdbc:mysql://192.168.99.100:3306/DB"
db.default.connectionPool = disabled

with the same results.

I have tried turning evolutions off but it only defers same error.

I have tried to adjust some other projects from github to my configuration (https://github.com/pedrorijo91/play-slick3-steps/tree/step3) and I got same results.

I would highly appreciate your help.

Regards,
Greg 

Mike Nielsen

unread,
Aug 17, 2016, 9:46:10 AM8/17/16
to play-fr...@googlegroups.com
Have you tried putting the username and password in the URI?

See here for example.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/898a56ce-7a66-4756-9ac3-ef30d71f3883%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Grzegorz Kamola

unread,
Aug 17, 2016, 10:25:45 AM8/17/16
to play-fr...@googlegroups.com
Indeed, 

slick.dbs.default.db.url = "jdbc:mysql://192.168.99.100/DB?user=X&password=Y"

has helped. Thank you!

To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/Tgiin5iB524/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/6D9006B9-71B8-4315-970A-95865A590B28%40xichar.com.

For more options, visit https://groups.google.com/d/optout.



--
Grzegorz Kamola
Reply all
Reply to author
Forward
0 new messages