Skip to content

Instantly share code, notes, and snippets.

@jsloyer
Last active August 29, 2015 14:07
Show Gist options
  • Save jsloyer/f94c079255bafca6d543 to your computer and use it in GitHub Desktop.
Save jsloyer/f94c079255bafca6d543 to your computer and use it in GitHub Desktop.
private JSONArray cloudant;
private JSONObject cloudantInstance;
private JSONObject cloudantCredentials;
public CloudantClient()
{
this.httpClient = null;
try {
String VCAP_SERVICES = System.getenv("VCAP_SERVICES");
JSONObject vcap;
vcap = (JSONObject) JSONObject.parse(VCAP_SERVICES);
cloudant = (JSONArray) vcap.get("cloudantNoSQLDB");
cloudantInstance = (JSONObject) cloudant.get(0);
cloudantCredentials = (JSONObject) cloudantInstance.get("credentials");
} catch (IOException e) {
e.printStackTrace();
}
this.port = Config.CLOUDANT_PORT;
this.host = (String) cloudantCredentials.get("host");
this.username = (String) cloudantCredentials.get("username");
this.password = (String) cloudantCredentials.get("password");
this.name = Config.CLOUDANT_NAME;
this.dbc = this.createDBConnector();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment