Reputation: 266988
I'm using IntelliJ 13, my build.sbt looks like:
name := "hello"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
//"org.apache.tomcat" %% "tomcat-jdbc" % "8.0.5",
"mysql" % "mysql-connector-java" % "5.1.30",
"com.typesafe.slick" %% "slick" % "2.0.1"
)
play.Project.playScalaSettings
My model is giving compilation errors:
package models
import java.sql.Date
import scala.slick.model.Table
import scala.slick.lifted.Tag
import scala.slick.direct.AnnotationMapper.column
import scala.slick.driver.JdbcProfile
import scala.slick.driver.MySQLDriver._
//class Actions(tag: Tag) extends Table[(Int, String, String, String, Int, Int, Int, Int, Date, Date)](tag, "actions") {
class Actions(tag: Tag) extends Table[(Int, String, String, Date, Date)](tag, "actions") {
def id = column[Int]("id", O.PrimaryKey)
def name = column[String]("name")
def description = column[String]("description")
def createdAt = column[Date]("created_at")
def updatedAt = column[Date]("updated_at")
def * = (id, name, description, createdAt, updatedAt)
}
The compile errors are:
Error:(10, 33) scala.slick.model.Table does not take type parameters
class Actions(tag: Tag) extends Table[(Int, String, String, Date, Date)](tag, "actions") {
^
Error:(10, 14) too many arguments for constructor Object: ()Object
class Actions(tag: Tag) extends Table[(Int, String, String, Date, Date)](tag, "actions") {
^
Error:(11, 18) object column does not take type parameters.
def id = column[Int]("id", O.PrimaryKey)
^
Error:(12, 20) object column does not take type parameters.
def name = column[String]("name")
^
Error:(13, 27) object column does not take type parameters.
def description = column[String]("description")
^
Error:(15, 25) object column does not take type parameters.
def createdAt = column[Date]("created_at")
^
Error:(16, 25) object column does not take type parameters.
def updatedAt = column[Date]("updated_at")
^
I first wanted to use tomcat jdbc but I think that requires me to create some fancy jdbcwrapper so I just commented that out for now as I just want to get a simple connection working.
My db connection looks like:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/play-test"
db.default.user=root
db.default.pass=""
Upvotes: 1
Views: 947
Reputation: 7247
Replace all of your slick imports with only this one import:
import scala.slick.driver.MySQLDriver.simple._
Then you'll have Table
, Tag
, etc. all in scope.
Slick's samples might help: https://github.com/slick/slick-examples/blob/master/src/main/scala/com/typesafe/slick/examples/lifted/FirstExample.scala
And the documentation: http://slick.typesafe.com/doc/2.0.1/gettingstarted.html#quick-introduction
Upvotes: 6