4

I'm getting started with the Play Framework, and have a toy app that runs locally using an H2 in-memory database. My application.conf file looks like this:

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:my-app-db"
db.default.user=sa
db.default.password=""

However when I try to deploy the app to Heroku, using the Postgres database that they provide, the deployment fails:

org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"
2013-05-17T01:22:18.982766+00:00 app[web.1]:    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
2013-05-17T01:22:18.982827+00:00 app[web.1]:    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
2013-05-17T01:22:18.983634+00:00 app[web.1]:    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:112)
2013-05-17T01:22:18.982915+00:00 app[web.1]:    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
2013-05-17T01:22:18.982665+00:00 app[web.1]:    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:108)
2013-05-17T01:22:18.982981+00:00 app[web.1]:    at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
2013-05-17T01:22:18.983376+00:00 app[web.1]:    at java.sql.DriverManager.getConnection(DriverManager.java:200)

My Procfile is exactly as described in the getting started guide:

web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL} 

1 Answer 1

7

The problem was that these two properties were interfering with Postgres:

db.default.user=sa
db.default.password=""

(Postgres already has the username and password in the URL, as you can see if you run heroku config and look at the DATABASE_URL property.)

When I commented out the above two lines and pushed to Heroku again, Postgres worked properly, and H2 still worked locally.

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

1 Comment

Thanks for sharing. I can't believe this Q&A is only a month old ... I mean, Play 2.x is really not mature, documentation wise. This is a basic mistake that I ran into during the first deployment that involved a database while following all the official documentation.

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.