-1

I'm trying to get Slick 3.0 running with MySql. I've made the following changes to the hello-slick-3.0 activator project:

  1. In application.conf I've removed the h2mem1 entry and replaced it with:

    horridDBStuff = { url = "utterlyhorriddb.blahblahblah.us-west-2.rds.amazonaws.com:3306" driver = com.mysql.jdbc.Driver connectionPool = disabled keepAliveConnection = true }

  2. I've replaced each Database.forConfig("h2mem1") entry in the scala code with Database.forConfig("horridDBStuff")

  3. I've replaced each import slick.driver.H2Driver.api._ with import slick.driver.MySQLDriver.api._

  4. In build.sbt I've added to libraryDependencies the item "mysql" % "mysql-connector-java" % "5.1.35"

It compiles fine, but running gives the error Exception in thread "main" java.sql.SQLException: No suitable driver coming from the line val db = Database.forConfig("horridDBStuff").

How can I get Slick 3.0 running with MySql? Am I missing something simple here, or are there any other working examples? Thanks.

thund
  • 1,842
  • 2
  • 21
  • 31
  • Answered this some days back http://stackoverflow.com/questions/30164015/scala-and-mysql-jdbc-driver/30164614 :) – mohit Jun 01 '15 at 19:12

1 Answers1

0

Fixed it. The URL in application.conf was in the wrong format. Should be

url = "jdbc:mysql://utterlyhorriddb.blahblah.us-west-2.rds.amazonaws.com/aardvark_schema"

where you've already created ardvark_schema in your database.

(That fixes the db access issue that I was asking about, but you'll still get a key-spec error. To fix that you need to remove the O.PrimaryKey entry from Tables.scala for "COF_NAME", which is described here: How to get around Slick 3.0 schema creation getting errors due to key specs without length.)

Community
  • 1
  • 1
thund
  • 1,842
  • 2
  • 21
  • 31