I am trying to follow the slick2 examples using MySql. however when trying to connect to the database I am getting end exception
import scala.slick.driver.MySQLDriver.simple._
import slickTest.DB.SuppliersEntity
object slickTestDB {
def main(args: Array[String]) {
println("CreateDb!")
val schemaName = "slickTest"
val conn_str = "jdbc:mysql://localhost:3306/" + schemaName
val database = Database.forURL(conn_str,user="",password="",driver="com.mysql.jdbc.Driver")
}
}
getting this exception
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$$anon$4.<init>(JdbcBackend.scala:62)
at scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forURL(JdbcBackend.scala:61)
at scala.slick.jdbc.JdbcBackend$$anon$2.forURL(JdbcBackend.scala:23)
at slickTest.slickTestDB$.main(slickTestDB.scala:18)
at slickTest.slickTestDB.main(slickTestDB.scala)
You probably need to add the MySQL Connector library as a dependency in your project.
libraryDependencies += "mysql" % "mysql-connector-java" % "latest.release"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With