public void open() {
try {
mongo = new MongoClient(uri);
} catch (final Exception e) {
LOG.error("Connecting to MongoDB failed.", e);
throw new MongoException("Failed to connect to MongoDB. ", e);
}
try {
collection = mongo.getDB(uri.getDatabase()).getCollection(uri.getCollection());
} catch (final Exception e) {
LOG.error("Connected to MongoDB but failed in acquiring collection.", e);
throw new MongoException("Could not acquire specified collection.", e);
}
}