本文整理汇总了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;
}
开发者ID:giiwa,项目名称:giiwa,代码行数:26,代码来源:MongoHelper.java
示例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();
}
}
开发者ID:javahongxi,项目名称:whatsmars,代码行数:34,代码来源:MongoDBClient.java
示例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();
}
开发者ID:momega,项目名称:spacesimulator,代码行数:11,代码来源:MongoClientTest.java
示例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();
}
开发者ID:momega,项目名称:spacesimulator,代码行数:10,代码来源:MongoClientTest.java
示例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();
}
开发者ID:momega,项目名称:spacesimulator,代码行数:12,代码来源:MongoClientTest.java
示例6: listCollections
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Override
public ListCollectionsIterable<Document> listCollections()
{
return database.listCollections();
}
开发者ID:dd00f,项目名称:ibm-performance-monitor,代码行数:6,代码来源:ProfiledMongoDatabase.java
示例7: listCollections
import com.mongodb.client.ListCollectionsIterable; //导入依赖的package包/类
@Override
public ListCollectionsIterable<Document> listCollections() {
return null;
}
开发者ID:kantega,项目名称:respiro,代码行数:5,代码来源:MongoDBExchangesPlugin.java
注:本文中的com.mongodb.client.ListCollectionsIterable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论