Scala Playframework connect to mysql

I’m writting this because I had issues following the documentation that comes with playframework
the docs are wrong or at least for me it gave me an error.

The docs states that to connect to a mysql database server you have to do the following:

If you need to connect to another JDBC-compliant database, first add the corresponding driver library to your application dependencies in build.sbt e.g.:

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.18"

This above works ok, I had no problems.

Then add the corresponding JDBC configuration to the conf/application.conf file:

db.url=jdbc:mysql:database_name
db.driver=org.mysql.Driver
db.user=root
db.pass=secret

This above now has problems namely the db.driver section it returned me an error
java.lang.ClassNotFoundException: org.mysql.Driver

Searching the internet I found this answer

http://solvedstack.com/questions/steps-needed-to-use-mysql-database-with-play-framework-2-0

So the correct working version is:

db.default.driver=com.mysql.jdbc.Driver
db.default.user=root
db.default.pass=secret

db.default.url=”jdbc:mysql://localhost/database_name?characterEncoding=UTF-8″

Maybe for others this is easy to spot but for me it wasn’t.

Sobre Fernando André
SysAdmin, Website and Application Developer

Deixe uma Resposta

Please log in using one of these methods to post your comment:

Logótipo da WordPress.com

Está a comentar usando a sua conta WordPress.com Terminar Sessão / Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão / Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão / Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão / Alterar )

Connecting to %s

%d bloggers like this: