I'm playing around a bit with the MongoDB driver for Java. So I just created a simple application to connect to a MongoDB server and select a database.
So I created an instance of MongoClient
and selected a 'DB':
try
{
MongoClient client = new MongoClient("localhost", 27017);
DB database = client.getDB("example");
}catch(Exception e){
e.printStackTrace();
}
Because of the fact that there is no running instance of mongod
on my machine, I expected that client
would throw an Exception
. Unfortunately that isn't the case.
Even when selecting the database nothing happens. It just behaves like if there was a running mongod
instance.
I looked into the documentation about the Java driver but couldn't find anything about it. Same with Google.
Is there anything I missed?
I'm using the latest MongoDB driver (version 2.12.2) from the official website.