Postgres on Openshift Java
Using an openshift JBoss/Postgres setup trying to create a webapp with a postgres database.
Turns out that the openshift ${OPENSHIFT_POSTGRESQL_DB_URL} variable does not work with the postgres 9.2 JDBC driver.
It’s broken.
The URL should be: jdbc:postgres://hostname:port/database. The URL provided by openshift is not that format.
Note also that SSL is not supported by the database server.
Here is the properties placeholder I’m using with Spring.
driver_class=org.postgresql.Driver
url=jdbc:postgresql://x.y.z.a:5432/
username=nottherealusername
password=thepasswordforpgsql
I know that the system creates a JNDI connection, but my maven build copies a properties file if the Openshift profile is run, and copies a different properties file if it’s building locally. This allows the proper database connection to be made depending on where it is built.