1

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.

1
  • If it starts with postgres: not postgresql: then that's a big, nasty bug that they really need to fix ... but it's kind of hard to believe it wouldn't have come up before. Can you provide a minimal self-contained test case that can be deployed to heroku to demonstrate the problem? Commented Nov 16, 2012 at 5:35

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

When I add the db.default.url and db.default.driver to my application.conf as you show, I now get a compilation failure when I push to heroku claiming "application.conf: Could not resolve substitution to a value: ${DATABASE_URL}". I do show DATABASE_URL when I ruy heroku config though.
I was able to get past that step by enabling compile time env vars. devcenter.heroku.com/articles/labs-user-env-compile