本文整理汇总了Scala中java.sql.Driver类的典型用法代码示例。如果您正苦于以下问题:Scala Driver类的具体用法?Scala Driver怎么用?Scala Driver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Driver类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: DatabaseSpec
//设置package包名称以及导入依赖的类
import java.sql.{Driver, DriverManager}
import org.scalatest.BeforeAndAfter
import org.scalatestplus.play.PlaySpec
import play.api.Logger
import scalikejdbc._
import scalikejdbc.config.DBs
import scala.collection.mutable.Stack
class DatabaseSpec extends PlaySpec with BeforeAndAfter {
implicit var session = AutoSession
before {
DBs.setupAll()
}
after {
DBs.closeAll()
}
"Database" must {
"List of database drivers" in {
val drivers = DriverManager.getDrivers
while (drivers.hasMoreElements) {
val driver:Driver = drivers.nextElement()
Logger.info(driver.toString)
}
}
"Fetch users" in {
val sql: SQL[Nothing, NoExtractor] = sql"select * from users"
val map: SQL[Map[String, Any], HasExtractor] = sql.toMap
val list: SQLToList[Map[String, Any], HasExtractor] = map.list
val users: List[Map[String, Any]] = list.apply()
}
}
"Slick" must {
"How to use Scala test" in {
// TODO
}
"throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[Int]
a [NoSuchElementException] must be thrownBy {
emptyStack.pop()
}
}
}
}