1

I'm trying to connect to postgres via play slick.

my application conf file

slick.dbs.default.driver= "slick.driver.PostgresDriver$"
slick.dbs.default.db.dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
slick.dbs.default.db.properties.driver = "org.postgresql.Driver"
slick.dbs.default.db.url = url
slick.dbs.default.db.user=username
slick.dbs.default.db.password=password

Normally I connect via val connection = DB.getConnection()

How to connect when i'm using click?

1 Answer 1

1

add to your application.conf an entry like:

slick.dbs {
  default.driver="slick.driver.PostgresDriver$"
  default.db.driver="org.postgresql.Driver"
  default.db.url=url
  default.db.user=user
  default.db.password=password
}

then, to get the connection (since this config is DatabaseConfig format) use:

val dbConfig: DatabaseConfig[PostgresDriver] = DatabaseConfig.forConfig("slick.dbs.default")
val db = dbConfig.db
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.