List of all collections in mongo database in java
问题 how can I get a list of all the collections in the database? database - mongodb; language - java; ide - eclipse; 回答1: Getting A List Of Collections Each database has zero or more collections. You can retrieve a list of them from the db (and print out any that are there) : Set<String> colls = db.getCollectionNames(); for (String s : colls) { System.out.println(s); } Edit : As suggested in @Andrew's answer, updated java client uses this : /** * Gets the names of all the collections in this