scala - Connecting Slick 3.2.1 to MySQL using slick.jdbc.MySQLProfile -


there 100s of threads on over how connect slick mysql , of them use "slick.driver.mysqldriver$". believe class deprecated , has been replaced "slick.jdbc.mysqlprofile"

this has been stated product documentation here

http://slick.lightbend.com/doc/3.2.1/api/#slick.driver.package

so in order use new class define configuration as

mysql = {   driver = "slick.jdbc.mysqlprofile"   properties = {     driver = "com.mysql.jdbc.driver"     url  = "jdbc:mysql://localhost:3306/foo"     user = "foo"     password = "bar"   } }  database.forconfig("mysql") 

but exception

java.lang.runtimeexception: failed load class of driverclassname slick.jdbc.mysqlprofile         @ com.zaxxer.hikari.hikariconfig.setdriverclassname(hikariconfig.java:323)         @ slick.jdbc.hikaricp.hikaricpjdbcdatasource$.$anonfun$forconfig$3(hikaricpjdbcdatasource.scala:31)         @ slick.jdbc.hikaricp.hikaricpjdbcdatasource$.$anonfun$forconfig$3$adapted(hikaricpjdbcdatasource.scala:31)         @ scala.option.map(option.scala:146)         @ slick.jdbc.hikaricp.hikaricpjdbcdatasource$.forconfig(hikaricpjdbcdatasource.scala:31) 

i tried many other combinations nothing seems work new class. right way connect when slick.driver.mysqldriver$ deprecated?

here librarydependencies build.sbt

"com.typesafe.slick" %% "slick" % "3.2.1", "com.typesafe.slick" %% "slick-hikaricp" % "3.2.1", "com.typesafe.slick" %% "slick-codegen" % "3.2.1", "mysql" % "mysql-connector-java" % "5.1.34", 

yes need connection pool.

edit: based on suggestion below changed config

mysql = {   profile = "slick.jdbc.mysqlprofile$"   properties = {     driver = "com.mysql.jdbc.driver"     url  = "jdbc:mysql://local:3306/foo"     user = "foo"     password = "bar"   } } 

but error

java.lang.illegalargumentexception: datasource or datasourceclassname or jdbcurl required.         @ com.zaxxer.hikari.hikariconfig.validate(hikariconfig.java:786)         @ com.zaxxer.hikari.hikaridatasource.<init>(hikaridatasource.java:67)         @ slick.jdbc.hikaricp.hikaricpjdbcdatasource$.forconfig(hikaricpjdbcdatasource.scala:58)         @ slick.jdbc.hikaricp.hikaricpjdbcdatasource$.forconfig(hikaricpjdbcdatasource.scala:21) 

the documentation suggests put in config:

profile = "slick.jdbc.mysqlprofile$" 

note $ @ end of line.

also, add following enable connection pooling:

datasourceclass = "slick.jdbc.databaseurldatasource" 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -