Java 类com.mongodb.client.ListCollectionsIterable 实例源码

项目:giiwa    文件:MongoHelper.java   
@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;
}
项目:whatsmars    文件:MongoDBClient.java   
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();
        }
    }
项目:spacesimulator    文件:MongoClientTest.java   
@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();
}
项目:ibm-performance-monitor    文件:ProfiledMongoDatabase.java   
@Override
public ListCollectionsIterable<Document> listCollections()
{
    return database.listCollections();
}
项目:ibm-performance-monitor    文件:ProfiledMongoDatabase.java   
@Override
public <TResult> ListCollectionsIterable<TResult> listCollections(Class<TResult> resultClass)
{
    return database.listCollections(resultClass);
}
项目:respiro    文件:MongoDBExchangesPlugin.java   
@Override
public ListCollectionsIterable<Document> listCollections() {
    return null;
}
项目:respiro    文件:MongoDBExchangesPlugin.java   
@Override
public <TResult> ListCollectionsIterable<TResult> listCollections(Class<TResult> tResultClass) {
    return null;
}