public boolean mongoDbCollectionNameUpdate(String oldName,String newName){
/连接MongoDB数据库/
MongoClient mongoClient = MongoClients.create(mongourl);
MongoDatabase country = mongoClient.getDatabase("Country");
/判断是否存在该集合/
boolean collectionExists = country.listCollectionNames().into(new ArrayList
/改名/
if (collectionExists){
MongoCollection
collection.renameCollection(new MongoNamespace("Country",newName),new RenameCollectionOptions().dropTarget(false));
return true;
}
System.out.println("该集合不存在");
return false;
}