i use java mongodb core. everything is okay but. logging infos -.-
[23:17:33] Connecting to MongoDB...
[main] INFO org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[main] INFO org.mongodb.driver.cluster - No server chosen by ReadPreferenceServerSelector{readPreference=primary} from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, serverDescriptions=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out
[cluster-ClusterId{value='598cbf5e4abca723f8603d80', description='null'}-localhost:27017] INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017
Java codes:
public class MongoDB {
public MongoClient client = null;
public Map<String, MongoDatabase> databaseTracker = new HashMap<String, MongoDatabase>();
public MongoDB(String host, int port) {
try {
this.client = new MongoClient( "localhost" , 27017 );
MongoDatabase database = this.client.getDatabase("Main");
System.out.println(Arrays.toString(this.getDatabaseNames().toArray()));
} catch(Exception e){
System.out.println("MongoDB Connection Error");
}
}
public List<String> getDatabaseNames(){
List<String> dbs = new ArrayList<String>();
MongoCursor<String> dbsCursor = this.client.listDatabaseNames().iterator();
while(dbsCursor.hasNext()) {
dbs.add(dbsCursor.next());
}
return dbs;
}
public ServerAddress address() {
if(this.client != null) {
return this.client.getAddress();
}
return null;
}
}
Level.SEVERE
didn't work :(
Please help, i need this.