Play framework cannot connect to PostgreSQL

635 views
Skip to first unread message

qwertyuiopasd...@gmail.com

unread,
Jul 20, 2016, 11:45:43 AM7/20/16
to play-framework
I have an Application.conf like this...

db.default.username="databaseUserName"
db
.default.password= "databaseUserPassword"
db
.default.driver=org.postgresql.Driver
db
.default.url="jdbc:postgresql://database.url:5432/database_seed"


When my Linux terminal user is named "databseUserName", it works. But if my Linux terminal user name is "foobar", I get...

[error] c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sleeping for 0ms and trying again.
Attempts left: 0. Exception: null.Message:FATAL: password authentication failed for user "foobar"[error] application -


! @70nb343n7 - Internal server error, for (GET) [/] ->


play
.api.Configuration$$anon$1: Configuration error[Cannot connect to database [default]]
 at play
.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94) ~[play_2.11-2.3.6.jar:2.3.6]
 at play
.api.Configuration.reportError(Configuration.scala:743) ~[play_2.11-2.3.6.jar:2.3.6]
 at play
.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:247) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
 at play
.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238) ~[play-jdbc_2.11-2.3.6.jar:2.3.6]
 at scala
.collection.immutable.List.map(List.scala:273) ~[scala-library-2.11.8.jar:na]
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "johnreed"
 at org
.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:408) ~[postgresql-9.3-1102-jdbc4.jar:na]
 at org
.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:181) ~[postgresql-9.3-1102-jdbc4.jar:na]
 at org
.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64) ~[postgresql-9.3-1102-jdbc4.jar:na]
 at org
.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:144) ~[postgresql-9.3-1102-jdbc4.jar:na]
 at org
.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29) ~[postgresql-9.3-1102-jdbc4.jar:na]

How do I make it connect regardless of what my USER name is in the terminal?

Igmar Palsenberg

unread,
Jul 21, 2016, 5:47:06 AM7/21/16
to play-framework
 
When my Linux terminal user is named "databseUserName", it works. But if my Linux terminal user name is "foobar", I get...
 
How do I make it connect regardless of what my USER name is in the terminal?

By turning on username / password auth, and not relying on ident auth. See https://stackoverflow.com/questions/4328679/how-to-configure-postgresql-so-it-accepts-loginpassword-auth for example.



Igmar 

hans

unread,
Jul 27, 2016, 5:14:22 PM7/27/16
to play-framework
Hi,

The next command lline reproduces exactly what you are doing from java, please try the next command from your shell:
psql --port 5432 -U databaseUserName -h database.url -W database_seed

When asked for the password use your password.

Hans
Reply all
Reply to author
Forward
0 new messages