Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.concurrent.duration._
- import scala.concurrent.Await
- import slick.jdbc.PostgresProfile.api._
- import scala.util.{Failure, Success, Try}
- object Main {
- def main(args: Array[String]): Unit = {
- val actionTimeout = 10 second
- val driver = "org.postgresql.Driver"
- val onlyHostNoDbUrl = s"jdbc:postgresql://localhost:5432/"
- val db = Database.forURL(onlyHostNoDbUrl, user = "postgres", password = "postgres", driver = driver)
- println(db.source.maxConnections.getOrElse("none"))
- val createDatabase = sqlu"""CREATE DATABASE SAMPLE"""
- val dropDatabase = sqlu"""DROP DATABASE SAMPLE"""
- Try {
- Await.result(db.run(createDatabase), actionTimeout)
- } match {
- case Success(_) => println("created Database")
- case Failure(e) => println(s"Error creating Database. ${e.getMessage}")
- }
- }
- }
Add Comment
Please, Sign In to add comment