I am doing Mongo DB Java side development and want to connect to Mongo DB instance. I read the authentication part from this link http://mongodb.github.io/mongo-java-driver/3.0/driver/reference/connecting/authenticating/. And it has below method to be used for authentication.
MongoCredential credential = MongoCredential.createCredential(user,
database,
password);
The above code works fine but I need to know the database name first. How to connect to Mongo DB without specifying database? I want to connect to it and return the list of databases for users to select.