I'm getting started with MongoDB in Java, and I'm trying to print my databases.
I'm using the following code and .getDatabaseNames()
is deprecated, is there a better way to do this? Or it doesn't matter? It is working fine. Thanks in advance.
private static void printDatabases(MongoClient mongo) {
List<String> dbs = mongo.getDatabaseNames();
for (String db : dbs) {
System.out.println(" - " + db);
}
}