Mongodb java 怎样连接呢?我知道有个mongo
2个回答
展开全部
MongoCredential credential = MongoCredential.createCredential("myUserAdmin", "mydb", "abc123".toCharArray());
//IP port
ServerAddress addr = new ServerAddress("10.168.10.41", 27017);
MongoClient client = new MongoClient(addr, Arrays.asList(credential));
MongoDatabase database = client.getDatabase("mydb");
这是带证书的,不带证书的:
MongoClient mongoClient = new MongoClient("10.168.10.41", 27017);
MongoDatabase database = mongoClient.getDatabase("mydb");
//IP port
ServerAddress addr = new ServerAddress("10.168.10.41", 27017);
MongoClient client = new MongoClient(addr, Arrays.asList(credential));
MongoDatabase database = client.getDatabase("mydb");
这是带证书的,不带证书的:
MongoClient mongoClient = new MongoClient("10.168.10.41", 27017);
MongoDatabase database = mongoClient.getDatabase("mydb");
2016-05-18
展开全部
去mongo网站下载JAVA驱动程序并查看SDK文档。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询