slick & sqlite : Could not instantiate class tests.SqliteSpec: org.sqlite.JDBC

試著忘記壹切 提交于 2019-12-11 19:52:29

问题


I try to begin an app with scala, play, slick, specs2 & sqlite.here is a trait for sqlite integration:

import scala.slick.driver.SQLiteDriver.simple._
import metier.Objets._
import scala.slick.lifted.ProvenShape
import java.sql.Date


package models {



trait sqlite {

val db = Database.forURL("jdbc:sqlite:rdvs.txt", driver = "org.sqlite.JDBC")
//val db = Database.forDataSource(DB.getDataSource())  

class Personnes(tag: Tag) extends Table[Rdv](tag, "RDV") {

  def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
  def nom = column[String]("NOM", O.NotNull)
  def prénom = column[String]("PRENOM")
  def sexe = column[Int]("SEXE")
  def télPortable = column[String]("TELPOR")
  def télBureau = column[String]("TELBUR")
  def télPrivé = column[String]("TELPRI")
  def siteRDV = column[String]("SITE")
  def typeRDV = column[String]("TYPE")
  def libelléRDV = column[String]("LIBELLE")
  def numRDV = column[String]("NUMRDV")
  def étape = column[String]("ETAPE")
  def dateRDV = column[Date]("DATE")
  def heureRDVString = column[String]("HEURE")
  def statut = column[String]("STATUT")
  def orderId = column[String]("ORDERID")

  def * = (id.?, nom, prénom, sexe, télPortable, télBureau, télPrivé,
    siteRDV, typeRDV, libelléRDV, numRDV, étape, dateRDV, heureRDVString,
    statut, orderId) <> (Rdv.tupled, Rdv.unapply _)

}

}

}

the test is this:

package tests {

@RunWith(classOf[JUnitRunner])
class SqliteSpec extends Specification with sqlite {

sequential

"la base sqlite" should {

  "create a new database file" in new Sqlite_avant_chaque_test {

    todo
  }
}

class Sqlite_avant_chaque_test extends Scope {

  println("avant test")

  //db.withDynSession {
  db.withSession { implicit session: Session =>
    val personnes = TableQuery[Personnes]
    personnes.ddl.create
    println("avant tests, après création base")
  }

}

} 
}

and when I launch the test in eclipse I get this error:

java.lang.Exception: Could not instantiate class tests.SqliteSpec: org.sqlite.JDBC

In my test class, I however have this import :

import scala.slick.driver.SQLiteDriver.simple._

which should load the sqlite driver of slick.

can you help me?

来源:https://stackoverflow.com/questions/21320819/slick-sqlite-could-not-instantiate-class-tests-sqlitespec-org-sqlite-jdbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!