标签:
import com.mongodb.MongoClient;
MongoClient mongoClient = new MongoClient();
连接MongoDB实例,默认为localhost,27017端口
MongoClient还提供了其他的构造方法
MongoClient mongoClient1 = new MongoClient("localhost");
MongoClient mongoClient2 = new MongoClient("localhost", 27017);
import com.mongodb.client.MongoDatabase;
MongoDatabase db = mongoClient.getDatabase("test");
访问 “test” 数据库
标签:
原文地址:http://www.cnblogs.com/simple-ly/p/5795577.html