Skip to content

Instantly share code, notes, and snippets.

@jasonmccay
Created October 17, 2011 01:28
Show Gist options
  • Save jasonmccay/1291713 to your computer and use it in GitHub Desktop.
Save jasonmccay/1291713 to your computer and use it in GitHub Desktop.
// Here, we are adding a string named "my_collections" that will hold the names of the collection.
public static void main(String[] args) throws UnknownHostException {
Mongo m = new Mongo( "hatch.mongohq.com" , 10004 );
DB db = m.getDB("my_database_name");
boolean auth = db.authenticate("cloudbees", "my_database_password".toCharArray());
Set<String> my_collections = db.getCollectionNames();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment