Guest User

Untitled

a guest
Feb 23rd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import scala.concurrent.duration._
  2. import scala.concurrent.Await
  3. import slick.jdbc.PostgresProfile.api._
  4.  
  5. import scala.util.{Failure, Success, Try}
  6. object Main {
  7. def main(args: Array[String]): Unit = {
  8. val actionTimeout = 10 second
  9. val driver = "org.postgresql.Driver"
  10. val onlyHostNoDbUrl = s"jdbc:postgresql://localhost:5432/"
  11.  
  12. val db = Database.forURL(onlyHostNoDbUrl, user = "postgres", password = "postgres", driver = driver)
  13. println(db.source.maxConnections.getOrElse("none"))
  14.  
  15. val createDatabase = sqlu"""CREATE DATABASE SAMPLE"""
  16. val dropDatabase = sqlu"""DROP DATABASE SAMPLE"""
  17.  
  18. Try {
  19. Await.result(db.run(createDatabase), actionTimeout)
  20. } match {
  21. case Success(_) => println("created Database")
  22. case Failure(e) => println(s"Error creating Database. ${e.getMessage}")
  23. }
  24.  
  25. }
  26.  
  27. }
Add Comment
Please, Sign In to add comment