无法使用MongoClient建立与MongoDB AWS实例的连接

时间:2016-05-24 12:59:37

标签: mongodb mongodb-query mongodb-java

我无法使用java中的mongoclient库与位于aws实例中的mongodb建立连接

ext install cordova-tools

我收到以下错误:

public static final String MONGO_HOSTNAME = "mongodb://10.174.19.120:27017,10.162.45.16:27017/?replicaSet=rs0";
MongoClientURI mongoClientURI = new MongoClientURI(MONGO_HOSTNAME);
MongoClient mongo = new MongoClient(mongoClientURI);

    List<String> dbs  = mongo.getDatabaseNames();
    System.out.println(dbs);

    // Now connect to your databases
    DB db = mongo.getDB(MONGO_DB);
    long count = db.getCollection(COLLECTION_NAME).count();

0 个答案:

没有答案