Reputation:
I've been having a heck of a time getting my Play! framework java app to run on Heroku, and I think I've narrowed it down to the Postgres JDBC driver not liking Heroku's DATABASE_URL parameter because it starts with postgres: and not postgresql:.
What is the proper way to configure a play! 2.0 app to connect to a heroku-provided Postgres instance?
I've tried variations on the following: PLAY_OPTS="-Ddb.default.url=$DATABASE_URL -Ddb.default.driver=org.postgresql.Driver"
But upon startup I get a SQLException that no suitable driver can be found for $DATABASE_URL.
Upvotes: 1
Views: 1720
Reputation: 244
No need to pass them in as system properties you can pickup Heroku environment variables in your application.conf
file
...
db.default.driver=org.postgresql.Driver
db.default.url=${DATABASE_URL}
Then define this in your Procfile
web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -Dconfig.resource=application.conf
It should pick up the DATABASE_URL
property for the Heroku environment. Although, I recommend creating a configuration file that is specific for the Heroku environment (i.e. heroku-prod.conf), but this is just an example.
Upvotes: 2