I have an Heroku account and I created an app and an Heroku-Postgres database. I already commited the app to the Heroku cloud, but I cannot access to the DB that I created.
I'm using play, and when i connect my project in my local DB, the application.conf configurations are:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/postgres"
db.default.user=postgres
db.default.password=password
And run my server locally and it works fine.
Before I upload my app to Heroku I changed this file to access my Heroku-Postgres DB:
db.default.driver=org.postgresql.Driver db.default.url="jdbc:postgresql://url:5432/database_name?user=name&password=pass&ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory"
The user and password fields are no longer needed. I've already created a file in the root of my project named "Procfile" that has:
web: target/universal/stage/bin/playsense -Dhttp.port=${PORT} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL}
I discovered this on the documentation. I don't understand why it doesn't connect to my DB. I used pgAdminIII with the DB credentials and it works fine.
It's something missing/wrong and I don't know what.
Can someone help me?
You probably need to unset the db.default.user
and db.default.password
config params when running on Heroku. But I'm not sure of an easy way to do that. So what I usually do is to not set them in the conf/application.conf
and instead I do something like:
db.default.driver=org.postgresql.Driver
db.default.url="postgres://postgres:password@localhost:5432/postgres"
db.default.url=${?DATABASE_URL}
#db.default.user=postgres
#db.default.password=password
That provides a default db.default.url
but overrides it with the DATABASE_URL
env var if it is set.