Reputation: 27375
I've creted a new database in openshift:
PostgreSQL 9.2 database added. Please make note of these credentials:
Root User: xxxxxxxxx
Root Password: xxxxxxxxxx
Database Name: xxxxxxxx
Connection URL: postgresql://$OPENSHIFT_POSTGRESQL_DB_HOST:$OPENSHIFT_POSTGRESQL_DB_PORT
I need to connect to the database manually via psql. How can I do that? I mean, how can I enquire that variable?
Upvotes: 1
Views: 1887
Reputation: 3867
You need to read environment variables in Java like this:
String envVar = System.getenv("OPENSHIFT_ENV_VAR");
In your case:
String dbHost = System.getenv("OPENSHIFT_POSTGRESQL_DB_HOST");
String dbPort = System.getenv("OPENSHIFT_POSTGRESQL_DB_PORT");
Read more at the Openshift docs, "Using Environment Variables".
Upvotes: 2