1
如何使用InteliJ IDE上的Scala Slick库连接到MySQL数据库? 找不到任何示例。我可以用下面的例子成功地连接到PostgreSQL数据库,但是如何连接到MySQL或SQLite?Scala使用InteliJ-IDE连接到MySQL数据库
def main(args: Array[String]): Unit = {
val connectionUrl = "jdbc:postgresql://localhost/scala_test?user=postgres&password=kurmis"
println("Postgresql oppened ")
Database.forURL(connectionUrl, driver = "org.postgresql.Driver") withSession {
implicit session =>
val users = TableQuery[testas]
for (a <- 1 to 100) {
val r = scala.util.Random
users.map(u => (u.nr, u.pirmas, u.antras, u.trecias, u.ketvirtas, u.penktas, u.sestas, u.septinas, u.astuntas, u.devintas)
)+= (a, r.nextInt.toString, r.nextInt.toString, r.nextInt.toString, r.nextInt.toString,
r.nextInt.toString, r.nextInt.toString, r.nextInt.toString, r.nextInt.toString, r.nextInt.toString)
}