List of usage examples for com.mongodb.client MongoDatabase listCollections
ListCollectionsIterable<Document> listCollections();
From source file:com.baifendian.swordfish.common.job.struct.datasource.MongoDatasource.java
License:Apache License
@Override public void isConnectable() throws Exception { MongoClient mongoClient = new MongoClient(new MongoClientURI(this.address)); try {//from w w w . ja va2 s.c o m MongoClientOptions options = MongoClientOptions.builder().connectTimeout(10).socketKeepAlive(false) .build(); MongoDatabase db = mongoClient.getDatabase(this.database); for (Document doc : db.listCollections()) { logger.debug("{}", doc); } } finally { mongoClient.close(); } }