Question

When I try to use the new proprietary MS SQL driver, I get an exception which boils down to a ClassNotFound for the driver class.

I include both slick and slick-extensions:

"com.typesafe.slick" %% "slick" % "2.0.1",
"com.typesafe.slick" %% "slick-extensions" % "2.0.1"

Example use:

import com.typesafe.slick.driver.ms.SQLServerDriver.simple._

Database.forURL(url="jdbc:sqlserver://hostname:1433;databaseName=thedb1", driver = "com.typesafe.slick.driver.ms.SQLServerDriver", user="user", password="password" ) withSession { ...

Exception:

Ultimately, ClassNotFound for com.typesafe.slick.driver.ms.SQLServerDriver.

Was it helpful?

Solution

I ran across the same issue and was able to solve it by defining the following lines in the application.conf file (thanks to the help from the play-slick contributors here):

db.default.slickdriver=com.typesafe.slick.driver.ms.SQLServerDriver
db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver

Alternatively, you could use the jTDS driver from sourceforge like listed in the question's comments.

db.default.slickdriver=com.typesafe.slick.driver.ms.SQLServerDriver
db.default.driver=net.sourceforge.jtds.jdbc.Driver

I ended up doing the first option, which meant downloading the unmanaged dependency sqljdbc4.jar(available here) and placing it on the {play app root}/lib directory. Since the jTDS driver is available as a library dependency for build.sbt, I'd suggest trying that one first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top