I am using the following mongodb driver.
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.2</version>
</dependency>
Here's how I connect
String textUri = "mongodb://<username>:<password>@ds027155.mlab.com:27155/";
MongoClientURI uri = new MongoClientURI(textUri);
MongoClient m = new MongoClient(uri);
I get the error. However if I mention database name
String textUri = "mongodb://<username>:<password>@ds027155.mlab.com:27155/<db-name>";
It works without any issue.. Acutally I want to list all the databases present on the server. How do I do I mention uri without specifying the database name?
Also how do I list only user defined collections present in the DB.
MongoDatabase db = m.getDatabase("standupmeetingnotes");
ListCollectionsIterable<Document> listColl = db.listCollections();
MongoIterable<String> colls = db.listCollectionNames();
for (String s : colls) {
System.out.println(s);
}
It prints objectlabs-system, objectlabs-system.admin.collections, system.indexes also which are system defined collections apart from user defined ones.
Any way I will be able to omit those?
Thanks.