设为首页 加入收藏

TOP

浅谈Slick(1)- 基本功能描述(三)
2017-10-10 12:11:27 】 浏览:7409
Tags:浅谈 Slick 基本 功能 描述
tain
",price=828.0) 41 def getNameAndPrice(n: Int) = coffees.filter(_.id === n) 42 .map(r => (r.name,r.price)).result.head 43 44 val actions = for { 45 _ <- coffees.schema.create 46 _ <- qDelete 47 c1 <- qAdd1 48 c2 <- qAdd2 49 (n1,p1) <- getNameAndPrice(c1) 50 (n2,p2) <- getNameAndPrice(c2) 51 } yield (n1,p1,n2,p2) 52 import java.sql.SQLException 53 import scala.concurrent.Await 54 import scala.concurrent.duration._ 55 val db = Database.forURL("jdbc:h2:mem:demo", driver="org.h2.Driver") 56 Await.result( 57 db.run(actions.transactionally).map { res => 58 println(s"Add coffee: ${res._1},${res._2} and ${res._3},${res._4}") 59 }.recover { 60 case e: SQLException => println("Caught exception: " + e.getMessage) 61 }, Duration.Inf) 62 63 }

 

 

 

 

 

 

 

 

 

 

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇浅谈Slick(2)- Slick101:第一.. 下一篇IDEA 中scala 程序运行时的错误:..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目