本文整理汇总了Java中com.mongodb.client.ListCollectionsIterable类的典型用法代码示例。如果您正苦于以下问题:Java ListCollectionsIterable类的具体用法?Java ListCollectionsIterable怎么用?Java ListCollectionsIterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListCollectionsIterable类属于com.mongodb.client包,在下文中一共展示了ListCollectionsIterable类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listTables
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Override
public List<JSON> listTables(String db) {
MongoDatabase g = getDB(db);
List<JSON> list = new ArrayList<JSON>();
if (g != null) {
ListCollectionsIterable<Document> it = g.listCollections();
for (Document d : it) {
JSON j = JSON.create();
j.put("table_name", d.getString("name"));
j.putAll(d);
list.add(j);
}
}
Collections.sort(list, new Comparator<JSON>() {
@Override
public int compare(JSON o1, JSON o2) {
return o1.getString("table_name").compareToIgnoreCase(o2.getString("table_name"));
}
});
return list;
}
示例2: main
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
public static void main(String[] args) throws Exception{
MongoDBDriver mongoDBDriver = new MongoDBDriver();
try{
MongoDBConfig mongoDBConfig = new MongoDBConfig();
//mongoDBConfig.setAddresses("61.171.123.234:27017");
mongoDBConfig.setAddresses("61.171.123.234:27017");
List<MongoDBCredential> credentials = new ArrayList<MongoDBCredential>();
MongoDBCredential credential = new MongoDBCredential();
credential.setDatabaseName("whatsmars-common");
credential.setUsername("whatsmars");
//credential.setPassword("haodai.com");
credential.setPassword("passwordiscommon");
credentials.add(credential);
mongoDBConfig.setCredentials(credentials);
mongoDBDriver.setConfiguration(mongoDBConfig);
mongoDBDriver.init();
MongoDBClient client = new MongoDBClient();
client.setDatabaseName("whatsmars-common");
client.setMongoDBDriver(mongoDBDriver);
ListCollectionsIterable<Document> documents = client.getDatabase().listCollections();
MongoCursor<Document> it = documents.iterator();
while (it.hasNext()) {
Document item = it.next();
System.out.println(item.toJson());
}
it.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
mongoDBDriver.close();
}
}
示例3: herokuTest
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Test
public void herokuTest() throws UnknownHostException {
MongoCredential credential = MongoCredential.createMongoCRCredential("heroku_app25459577", "heroku_app25459577", "gsps2dbe8l7ovbot1jkto5lnid".toCharArray());
MongoClient mongoClient = new MongoClient(new ServerAddress("ds041841.mongolab.com" , 41841),
Arrays.asList(credential));
MongoDatabase db = mongoClient.getDatabase("heroku_app25459577");
ListCollectionsIterable<Document> list = db.listCollections();
System.out.println(list.toString());
mongoClient.close();
}
示例4: herokuUriTest
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Test
public void herokuUriTest() throws UnknownHostException {
MongoClientURI uri= new MongoClientURI("mongodb://heroku_app25459577:[email protected]:41841/heroku_app25459577");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase db = mongoClient.getDatabase(uri.getDatabase());
ListCollectionsIterable<Document> list = db.listCollections();
System.out.println(list);
mongoClient.close();
}
示例5: simpleTest
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Test
public void simpleTest() throws UnknownHostException {
MongoClientURI uri= new MongoClientURI("mongodb://spacesimulator:[email protected]:41651/spacesimulator");
MongoClient mongoClient = new MongoClient(uri);
MongoDatabase db = mongoClient.getDatabase(uri.getDatabase());
ListCollectionsIterable<Document> list = db.listCollections();
System.out.println(list);
MongoCollection<Document> projects = db.getCollection("projects");
Assert.assertNotNull(projects);
mongoClient.close();
}
示例6: listCollections
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Override
public ListCollectionsIterable<Document> listCollections()
{
return database.listCollections();
}
示例7: listCollections
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Override
public ListCollectionsIterable<Document> listCollections() {
return null;
}