本文整理汇总了Scala中slick.driver.MySQLDriver类的典型用法代码示例。如果您正苦于以下问题:Scala MySQLDriver类的具体用法?Scala MySQLDriver怎么用?Scala MySQLDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MySQLDriver类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: MySQLService
//设置package包名称以及导入依赖的类
package services
//import slick.driver.{JdbcProfile, PostgresDriver}
//import slick.driver.PostgresDriver.api._
import slick.driver.{JdbcProfile, MySQLDriver}
import slick.driver.MySQLDriver.api._
class MySQLService(jdbcUrl: String, dbUser: String, dbPassword: String) extends DatabaseService {
// Setup our database driver, Postgres in this case
// val driver: JdbcProfile = PostgresDriver
val driver: JdbcProfile = MySQLDriver
// Create a database connection
val db: Database = Database.forURL(jdbcUrl, dbUser, dbPassword)
db.createSession()
}
示例2: JdbcProfileProvider
//设置package包名称以及导入依赖的类
package au.com.agiledigital.dao.slick
import slick.driver.{ DerbyDriver, H2Driver, HsqldbDriver, JdbcProfile, MySQLDriver, PostgresDriver, SQLiteDriver }
trait JdbcProfileProvider {
type JP <: JdbcProfile
val driver: JP
}
object JdbcProfileProvider {
trait H2ProfileProvider extends JdbcProfileProvider {
type JP = H2Driver
val driver: H2Driver = H2Driver
}
trait PostgresProfileProvider extends JdbcProfileProvider {
type JP = PostgresDriver
val driver = PostgresDriver
}
trait DerbyProfileProvider extends JdbcProfileProvider {
type JP = DerbyDriver
val driver = DerbyDriver
}
trait HsqlProfileProvider extends JdbcProfileProvider {
type JP = HsqldbDriver
val driver = HsqldbDriver
}
trait MySQLProfileProvider extends JdbcProfileProvider {
type JP = MySQLDriver
val driver = MySQLDriver
}
trait SQLLiteProfileProvider extends JdbcProfileProvider {
type JP = SQLiteDriver
val driver = SQLiteDriver
}
}
示例3: Generate
//设置package包名称以及导入依赖的类
package org.example
import scala.reflect.runtime.{ universe => ru }
import slick.driver.MySQLDriver
object Generate {
def main(args: Array[String]): Unit = {
val slickDriver = "slick.driver.MySQLDriver"
val jdbcDriver = "com.mysql.jdbc.Driver"
val url = "jdbc:mysql://localhost:3306/automutton?characterEncoding=UTF8"
val outputFolder = "/Users/ishikawayuuki"
val pkg = "model"
val user = "root"
val password = ""
slick.codegen.SourceCodeGenerator.main(
Array(slickDriver, jdbcDriver, url, outputFolder, pkg, user, password)
)
}
}