javamysqlplayframeworkplayframework-1.x

Database [default] Driver not found - MySQL in Playframework 1.4.x


Can't seem to connect to connect to a locally hosted MySQL 5 database using the jdbc driver.

My application is simply the one created by running play new on 1.4.x and I added the following to my application.conf

 db.default.url="mysql://localhost:3306/test"
 db.default.driver="com.mysql.jdbc.Driver"
 db.default.user="jsmit"
 db.default.password="pass123"

When I try to hit localhost:9000, I get the following error:

 A database error occured : Cannot connected to the database[default], Database [default] Driver not found ("com.mysql.jdbc.Driver") 

As I understand, this driver should be packaged in mysql-java-connector shipped under framework/lib. I couldn't find anyone running into this issue on play 1.X.


Solution

  • looks like db.default.url needs to be loaded as an environment variable. In the example above, add the following in your shell's profile:

    export DB_URL="mysql://localhost:3306/test"
    

    and make your application.conf the following:

    db.default.url=${DB_URL}
    db.default.driver=com.mysql.jdbc.Driver
    db.default.user="jsmith"
    db.default.password="pass123"