1

I am having an issue on Pivotal Web Services where I am unable to get a connection to the Postgres SQL database for UAA.

I have the service defined and bound to the application, but am putting the credentials in manually (Not sure if param replacement happens in the an Env variable)

The relevant section of the UAA.yaml file:

database:
    driverClassName: org.postgresql.Driver
    url: jdbc:postgresql://babar.elephantsql.com:5432/db
    username: db
    password: randomPass
    maxactive: 15
    maxidle: 5
    minidle: 0
    removeabandoned: false
    logabandoned: true
    abandonedtimeout: 300
    evictionintervalms: 15000
    caseinsensitive: false 

I am bound to the ElephantSQL's "Panda" plan which limits me to 20 concurrent connections. This is the error I generally receive in UAA on startup:

java.sql.SQLException: Driver:org.postgresql.Driver@112ab411 returned null for URL:postgres://db:randomPass@babar.elephantsql.com:5432/db 2017-01-28T14:15:57.43-0500 [APP/PROC/WEB/0]OUT at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:296)

I am not sure why it is returning null, the credentials and url are correct.

StylePotato
  • 167
  • 1
  • 13
  • Maybe check your yaml with a tool to validate it's correct. White space matters so you could have a tab or something that's throwing it off. Tools like this help -> http://www.yamllint.com/ – Daniel Mikusa Jan 29 '17 at 20:20
  • The YAML if valid, I have checked it with a validator and there are no errors in the logs. – StylePotato Jan 30 '17 at 15:40

1 Answers1

0

The fact the logging shows URL:postgres://... would seem to indicate that the JDBC URL is getting mangled and jdbc: is stripped off. And it seems to have added username and password in the URL, which - as far as I know - is not supported by the PostgreSQL driver.

A JDBC driver that is asked to connect to a JDBC url it does not support, is required to return null by the JDBC specification/API.

In other words it seems either your configuration is wrong, or UAA does something wrong. As I don't know Cloudfoundry, I can't answer the specifics of that.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • It does the same thing for MySQL driver. The odd thing it that this works running on my local machine, just fails on CF. – StylePotato Jan 30 '17 at 15:40
  • Don't focus on the fact that it runs locally. It's a Spring app and the app can react to the environment & services where it's running. This means that the app may not run the same locally vs on CF (for example, it might use H2 or HSQL db locally vs Postgres or MySQL on CF, there are other differences though). What you're going to need are debug logs so you can see how UAA is starting up and what it's doing when this fails. – Daniel Mikusa Jan 31 '17 at 19:53