0
Mongo mongo = new Mongo();
DB db = mongo.getDB("db");
DBCollection collection = db.getCollection("collection");
方法2:
MongoClient client = new MongoClient("localhost", 27017);
MongoDatabase db = client.getDatabase("db");
MongoCollection<Document> collection = db.getCollection("collection");
哪個是優選的方法,爲什麼呢?兩種方法有哪些優點?