[2.2.0] Build.scala & Connecting to MYSQL Database (Driver not found)

425 views
Skip to first unread message

Adithya B M

unread,
Oct 24, 2013, 7:45:12 AM10/24/13
to play-fr...@googlegroups.com
Hi!!

I have just started picking up the Play Framework for a small web app.

Im following this document : http://www.playframework.com/documentation/2.2.x/ScalaDatabase and am not able to connect to my local MySql Database. [Configuration error - Driver not found: [com.mysql.jdbc.Driver] In /conf/application.conf]

Now, the ScalaDatabase document states I "need to add a dependency for the connector" for MySql:
val appDependencies = Seq(
  "mysql" % "mysql-connector-java" % "5.1.21"
)

Looking at others code from other threads, I have concluded that this line should be added to the file Build.scala in the projects directory. This file is no longer generated for me (as I have created a new project starting 2.2.0). Now, since the developers are trying to phase out this file, where is the dependency string supposed to be added so that the com.mysql.jdbc.Driver is found?

This doesn't work:
build.sbt:
name := "webapp1"

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache
  "mysql" % "mysql-connector-java" % "5.1.21"
)

play.Project.playScalaSettings


Thanks for helping out :)
Cheers!!

Yvonnick Esnault

unread,
Oct 24, 2013, 9:07:28 AM10/24/13
to play-fr...@googlegroups.com
Hi,

In your application.conf, you must have : 

db.default.driver=com.mysql.jdbc.Driver
db.default.url="mysql://user:password@host/schema"

See an example here : https://github.com/soapower/soapower/blob/master/conf/application.conf

Regards,

Yvonnick

Adithya B M

unread,
Oct 24, 2013, 10:00:46 AM10/24/13
to play-fr...@googlegroups.com
Hi,

My error is :

Driver not found: [com.mysql.jdbc.Driver] at the line db.default.driver=com.mysql.jdbc.Driver

I have the following in my application.conf: (I have tried combinations using all commented lines as well )

db.default.driver=com.mysql.jdbc.Driver
##db.default.driver=org.mysql.Driver
db.default.url="mysql://root:root@localhost/cls3"
#db.default.url="mysql://localhost/cls3"
#db.default.user=root
#db.default.password="root"
db.default.logStatements=true
logger.com.jolbox=DEBUG // for EBean
ebean.default="models.*"

Thanks for helping :)

Cheers!!

Adithya B M

unread,
Oct 25, 2013, 2:44:56 AM10/25/13
to play-fr...@googlegroups.com
Turns out you have to restart sbt after adding a dependancy. Didnt know that :)

Its working now.
Cheers!!

Johan Andren

unread,
Oct 25, 2013, 6:15:43 AM10/25/13
to play-fr...@googlegroups.com
You can also run 'reload' to make sbt reload the project configuration.
Reply all
Reply to author
Forward
0 new messages