Mysql Play2.4 slick Timeout exception

162 views
Skip to first unread message

Rahul Kumar

unread,
Jul 13, 2015, 5:50:21 PM7/13/15
to play-fr...@googlegroups.com
HI,
I am trying to use play 2.4, play-slick 1.0 with MySql database, but not able to connect with database. Please someone check if i am missing something. 

in application.conf following line i added

slick.dbs.mydb.driver="slick.driver.MySQLDriver$"
slick.dbs.mydb.db.driver="com.mysql.jdbc.Driver"
slick.dbs.mydb.db.url="jdbc:mysql://localhost/admin"
slick.dbs.mydb.user=root
slick.dbs.mydb.password="mypassword"

in build.sbt :

libraryDependencies += "com.typesafe.play" %% "play-slick" % "1.0.0"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "1.0.0"
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.35"

Code: 

class CatDAO @Inject()(@NamedDatabase("mydb") protected val dbConfigProvider: DatabaseConfigProvider) extends HasDatabaseConfigProvider[JdbcProfile] {
  import driver.api._

  private val Cats = TableQuery[CatsTable]

 def all(): Future[Seq[Cat]] = db.run(Cats.result)
 def insert(cat: Cat): Future[Unit] = db.run(Cats += cat).map { _ => () }

  private class CatsTable(tag: Tag) extends Table[Cat](tag, "CAT") {

    def name = column[String]("NAME", O.PrimaryKey)
    def color = column[String]("COLOR")

    def * = (name, color) <> (Cat.tupled, Cat.unapply _)
  }
}



Jake

unread,
Jul 20, 2015, 6:18:43 AM7/20/15
to play-fr...@googlegroups.com

I had a similar problem. Try extending the connection timeout period in your application.conf.

So my libraryDependencies is as follows:

  "com.typesafe.play" %% "play-slick-evolutions" % "1.0.0",
  "com.typesafe.play" %% "play-slick" % "1.0.0",
  "mysql" % "mysql-connector-java" % "latest.release",

and my application.conf

slick {
 dbs {
  default {
   driver="slick.driver.MySQLDriver$"
   db {
    driver=com.mysql.jdbc.Driver
    url="jdbc:mysql://localhost/playdb?useUnicode=true&characterEncoding=UTF-8"
    user=root
    password=""
    connectionTimeout = 15 second
    connectionTestQuery = "SELECT 1"
   }
  }
 }
}
Reply all
Reply to author
Forward
0 new messages