java类com.mongodb.client.MongoDatabase的实例源码

QueryDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 28 收藏 0 点赞 0 评论 0
/**
 * This method retrieve all the document(s)
 */
@Override
public void getAllDocuments() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());
        FindIterable<Document> docs = collection.find(); //SELECT * FROM sample;
        for (Document doc : docs) {
            log.info(doc.getString("name"));
        }
    } catch (MongoException | ClassCastException e) {
        log.error("Exception occurred while insert Value using **BasicDBObject** : " + e, e);
    }
}
DeleteDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 25 收藏 0 点赞 0 评论 0
/**
 * This is delete the single document, which is first matched
 */
@Override
public void deleteOneDocument() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    Bson query = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());
        query = eq("name", "sundar");
        DeleteResult result = collection.deleteMany(query);
        if (result.wasAcknowledged()) {
            log.info("Single Document deleted successfully \nNo of Document Deleted : " + result.getDeletedCount());
        }
    } catch (MongoException e) {
        log.error("Exception occurred while delete Single Document : " + e, e);
    }
}
DeleteDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 32 收藏 0 点赞 0 评论 0
/**
 * This is deleted delete all document(s), which is matched
 */
@Override
public void deleteManyDocument() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    Bson query = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());
        query = lt("age", 20);
        DeleteResult result = collection.deleteMany(query);
        if (result.wasAcknowledged()) {
            log.info("Document deleted successfully \nNo of Document(s) Deleted : "
                    + result.getDeletedCount());
        }
    } catch (MongoException e) {
        log.error("Exception occurred while delete Many Document : " + e, e);
    }
}
UnorganizedTests.java 文件源码 项目:digital-display-garden-iteration-3-sixguysburgers-fries 阅读 20 收藏 0 点赞 0 评论 0
@Test
public void incrementMetadata() {
//This method is called from inside of getPlantByPlantId();
    boolean myPlant = plantController.
            incrementMetadata("58d1c36efb0cac4e15afd278", "pageViews");
    assertFalse(myPlant);
    boolean myPlant2 = plantController.incrementMetadata("16001.0","pageViews");
    assertTrue(myPlant2);


//This is necessary to test the data separately from getPlantByPlantId();
    Document searchDocument = new Document();
    searchDocument.append("id", "16001.0");
    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection<Document> plantCollection = db.getCollection("plants");
    String before = JSON.serialize(plantCollection.find(searchDocument));
    plantController.incrementMetadata("16001.0","pageViews");
    String after = JSON.serialize(plantCollection.find(searchDocument));

    assertFalse(before.equals(after));
}
MongoManager.java 文件源码 项目:rocketmq-flink-plugin 阅读 25 收藏 0 点赞 0 评论 0
/**
 * @param dbName         表名
 * @param collectionName 集合名
 * @param saveJson       待存入JSON
 * @return 插入状态或异常信息
 */
@SuppressWarnings("unchecked")
public JSONObject executeInsert(String dbName, String collectionName, JSONObject saveJson) {
    JSONObject resp = new JSONObject();
    try {
        MongoDatabase db = mongoClient.getDatabase(dbName);
        MongoCollection coll = db.getCollection(collectionName);
        Document doc = Document.parse(saveJson.toString());
        coll.insertOne(doc);
    } catch (MongoTimeoutException e1) {
        e1.printStackTrace();
        resp.put("ReasonMessage", e1.getClass() + ":" + e1.getMessage());
        return resp;
    } catch (Exception e) {
        e.printStackTrace();
        resp.put("ReasonMessage", e.getClass() + ":" + e.getMessage());
    }
    return resp;
}
FlowerRating.java 文件源码 项目:digital-display-garden-iteration-4-dorfner-v2 阅读 23 收藏 0 点赞 0 评论 0
@Test
public void AddFlowerRatingReturnsTrueWithValidJsonInput() throws IOException{

    String json = "{like: true, id: \"58d1c36efb0cac4e15afd202\"}";

    assertTrue(plantController.addFlowerRating(json, "first uploadId") instanceof ObjectId);

    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection plants = db.getCollection("plants");

    FindIterable doc = plants.find(new Document().append("_id", new ObjectId("58d1c36efb0cac4e15afd202")));
    Iterator iterator = doc.iterator();
    Document result = (Document) iterator.next();

    List<Document> ratings = (List<Document>) ((Document) result.get("metadata")).get("ratings");
    assertEquals(1, ratings.size());

    Document rating = ratings.get(0);
    assertTrue(rating.getBoolean("like"));
    assertTrue(rating.get("id") instanceof ObjectId);
}
UpdateDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 25 收藏 0 点赞 0 评论 0
/**
 * This method update document with lastmodified properties 
 */
@Override
public void updateDocumentWithCurrentDate() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    Bson filter = null;
    Bson query = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());
        filter = eq("name", "Sundar");
        query = combine(set("age", 23), set("gender", "Male"),
                currentDate("lastModified"));
        UpdateResult result = collection.updateOne(filter, query);
        log.info("Update with date Status : " + result.wasAcknowledged());
        log.info("No of Record Modified : " + result.getModifiedCount());
    } catch (MongoException e) {
        log.error("Exception occurred while update Many Document with Date : " + e, e);
    }
}
BingoChessChallenge.java 文件源码 项目:BingoChess 阅读 20 收藏 0 点赞 0 评论 0
public BingoChessChallenge(String[] args) {
    announcer = new Chatter(args[0]);
    lichs = new HashMap<String,Lichesser>();
    chessplayers = new HashMap<String,ChessPlayer>();
    chessgames = new HashMap<String,LichessGame>();
    BingoPlayer.SQUARE_BAG = new Vector<Dimension>();
    for (int x=0;x<8;x++)
    for (int y=0;y<8;y++)
    BingoPlayer.SQUARE_BAG.add(new Dimension(x,y));
    initIRC(args[0], args[1], args[2], args[3]);
    loadAdmins("res/admins.txt");
    serv = new BingoServ(Integer.parseInt(args[4]),this);
    serv.startSrv();
    bingoURL = args[5];
    MongoClientURI connStr = new MongoClientURI("mongodb://bingobot:" + args[6] + "@localhost:27017/BingoBase");
    MongoClient mongoClient = new MongoClient(connStr);
    MongoDatabase bingoBase = mongoClient.getDatabase("BingoBase");
    playData = bingoBase.getCollection("players");
}
InsertDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 23 收藏 0 点赞 0 评论 0
/**
 * This method insert the single document
 */
@Override
public void insertSingleDocument() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());

        Document canvas = new Document("item", "canvas").append("qty", 100)
                .append("tags", singletonList("cotton"));

        Document size = new Document("h", 28).append("w", 35.5).append(
                "uom", "cm");

        canvas.append("size", size);
        collection.insertOne(canvas);
        log.info("Single Document Insert Successfully...");
    } catch (MongoException | ClassCastException e) {
        log.error("Exception occurred while insert **Single Document** : " + e, e);
    }
}
MongoDBs.java 文件源码 项目:rebase-server 阅读 24 收藏 0 点赞 0 评论 0
private static void initCollections(MongoDatabase db) {
    try {
        db.createCollection("users");
        db.createCollection("categories");
        db.createCollection("feeds");
        db.createCollection("licenses");
    } catch (Exception e) {
        Log.w(TAG, "[attemptCreateCollections] " + e.getMessage());
    }
    users = db.getCollection("users");
    categories = db.getCollection("categories");
    feeds = db.getCollection("feeds");
    licenses = db.getCollection("licenses");

    users.createIndex(
        Indexes.ascending(User.USERNAME),
        new IndexOptions().unique(true));

    categories.createIndex(
        Indexes.ascending(Category.OWNER, Category.KEY),
        new IndexOptions().unique(true));
}
MongoDBDaoImpl.java 文件源码 项目:Jerkoff 阅读 23 收藏 0 点赞 0 评论 0
@Override
public List<Document> find(String collection, String signature) {
    List<Document> res = new ArrayList<Document>();
    try {
        MongoDatabase db = mongoClient.getDatabase(databaseName);
        MongoCollection<Document> coll = db.getCollection(collection);
        BasicDBObject searchQuery = new BasicDBObject();
        searchQuery.put("signature", signature);
        Iterable<Document> docs = coll.find(searchQuery);
        for (Document doc : docs) {
            res.add(doc);
        }
    } catch (Exception e) {
        LOG.error(e);
    }
    return res;
}
DAO.java 文件源码 项目:Babler 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Saves an entry to file
 * @param entry
 * @param dbName usually scrapig
 * @return true if success
 */
public static boolean saveEntry(DBEntry entry, String dbName){

    if(entry == null || !entry.isValid())
        return false;

    Logger log = Logger.getLogger(DAO.class);

    MongoDatabase db = MongoDB.INSTANCE.getDatabase(dbName);

    String collectionName = getCollectionName(entry);


    MongoCollection collection = db.getCollection(collectionName,BasicDBObject.class);

    try {
        collection.insertOne(entry);
        return true;
    }
    catch (MongoWriteException ex){
        if (ex.getCode() != 11000) // Ignore errors about duplicates
            log.error(ex.getError().getMessage());
        return false;
    }

}
ExcelParser.java 文件源码 项目:digital-display-garden-iteration-2-spraguesanborn 阅读 30 收藏 0 点赞 0 评论 0
public static void populateDatabase(String[][] cellValues){
    MongoClient mongoClient = new MongoClient();
    MongoDatabase ddg = mongoClient.getDatabase("ddg");
    MongoCollection plants = ddg.getCollection("flowers");
    plants.drop();

    String[] keys = getKeys(cellValues);

    for (int i = 4; i < cellValues.length; i++){
        Map<String, String> map = new HashMap<String, String>();
        for(int j = 0; j < cellValues[i].length; j++){
            map.put(keys[j], cellValues[i][j]);
        }

        Document doc = new Document();
        doc.putAll(map);
        doc.append("thumbsUp", 0);
        doc.append("flowerVisits", 0);
        plants.insertOne(doc);
    }
}
MongoTest.java 文件源码 项目:Jerkoff 阅读 28 收藏 0 点赞 0 评论 0
@Test
@Ignore
public void testInsert() {
    MongoClient mongoClient = new MongoClient("localhost", 27017);
    try {
        MongoDatabase db = mongoClient.getDatabase("prova");
        MongoCollection<Document> coll = db.getCollection("prova");
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("signature", "void test()");
        map.put("param", convert(new Object[0]));
        map.put("returnValue", 1);
        map.put("exception", convert(new IllegalAccessError("prova")));
        Document doc = new Document(map);
        coll.insertOne(doc);
        LOG.info(doc);
    } catch (Exception e) {
        LOG.error(e);
    } finally {
        mongoClient.close();
    }
}
FlowerRating.java 文件源码 项目:digital-display-garden-iteration-4-dorfner-v2 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void AddFlowerRatingReturnsTrueWithValidInput() throws IOException{
    assertTrue(plantController.addFlowerRating("58d1c36efb0cac4e15afd202", true, "first uploadId") instanceof ObjectId);

    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection plants = db.getCollection("plants");

    FindIterable doc = plants.find(new Document().append("_id", new ObjectId("58d1c36efb0cac4e15afd202")));
    Iterator iterator = doc.iterator();
    Document result = (Document) iterator.next();

    List<Document> ratings = (List<Document>) ((Document) result.get("metadata")).get("ratings");
    assertEquals(1, ratings.size());

    Document rating = ratings.get(0);
    assertTrue(rating.getBoolean("like"));
    assertTrue(rating.get("id") instanceof ObjectId);
}
MongoTest.java 文件源码 项目:Jerkoff 阅读 25 收藏 0 点赞 0 评论 0
@Test
@Ignore
public void testRead() {
    MongoClient mongoClient = new MongoClient("localhost", 27017);
    try {
        MongoDatabase db = mongoClient.getDatabase("prova");
        MongoCollection<Document> coll = db.getCollection("prova");
        FindIterable<Document> res = coll.find();
        for (Document doc : res) {
            String thisObj = doc.getString("this");
            LOG.info(thisObj);
            String thisClass = doc.getString("thisClass");
            LOG.info(thisClass);
            Gson gson = new Gson();
            Class<?> cl = Class.forName(thisClass);
            Object obj = gson.fromJson(thisObj, cl);
            LOG.info(obj);
        }
    } catch (Exception e) {
        LOG.error(e);
    } finally {
        mongoClient.close();
    }
}
FeatureDatabaseMgmtManager.java 文件源码 项目:athena 阅读 26 收藏 0 点赞 0 评论 0
public HashMap<String, MongoCollection> getCollectionList(MongoDatabase mongoDatabase) {
    HashMap<String, MongoCollection> dbCollectionList = new HashMap<String, MongoCollection>();
    String[] tableNameList = {AthenaFeatureField.ERROR_MSG, AthenaFeatureField.FLOW_REMOVED,
            AthenaFeatureField.PACKET_IN,
            AthenaFeatureField.PORT_STATUS, AthenaFeatureField.FLOW_STATS, AthenaFeatureField.QUEUE_STATS,
            AthenaFeatureField.AGGREGATE_STATS, AthenaFeatureField.TABLE_STATS, AthenaFeatureField.PORT_STATS};

    for (String tableName : tableNameList) {
        MongoCollection dbCollection = mongoDatabase.getCollection(tableName);
        if (dbCollection == null) {
            mongoDatabase.createCollection(tableName);
            dbCollection = mongoDatabase.getCollection(tableName);
        }
        dbCollectionList.put(tableName, dbCollection);
    }

    return dbCollectionList;
}
TestPlantComment.java 文件源码 项目:digital-display-garden-iteration-3-sixguysburgers-fries 阅读 26 收藏 0 点赞 0 评论 0
@Test
public void successfulInputOfComment() throws IOException {
    String json = "{ plantId: \"58d1c36efb0cac4e15afd278\", comment : \"Here is our comment for this test\" }";

    assertTrue(plantController.storePlantComment(json, "second uploadId"));

    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection<Document> commentDocuments = db.getCollection("comments");

    long contains = commentDocuments.count();
    assertEquals(1, contains);

    Iterator<Document> iter = commentDocuments.find().iterator();

    Document fromDb = iter.next();

    assertEquals("Here is our comment for this test", fromDb.getString("comment"));
    assertEquals("16040.0", fromDb.get("commentOnPlant"));
    assertEquals("second uploadId", fromDb.get("uploadId"));
}
FlowerRating.java 文件源码 项目:digital-display-garden-iteration-3-sixguysburgers-fries 阅读 31 收藏 0 点赞 0 评论 0
@Test
public void AddFlowerRatingReturnsTrueWithValidInput() throws IOException{

    assertTrue(plantController.addFlowerRating("58d1c36efb0cac4e15afd202", true, "first uploadId"));

    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection plants = db.getCollection("plants");

    FindIterable doc = plants.find(new Document().append("_id", new ObjectId("58d1c36efb0cac4e15afd202")));
    Iterator iterator = doc.iterator();
    Document result = (Document) iterator.next();

    List<Document> ratings = (List<Document>) ((Document) result.get("metadata")).get("ratings");
    assertEquals(1, ratings.size());

    Document rating = ratings.get(0);
    assertTrue(rating.getBoolean("like"));
    assertEquals(new ObjectId("58d1c36efb0cac4e15afd202"),rating.get("ratingOnObjectOfId"));
}
TestPlantComment.java 文件源码 项目:digital-display-garden-iteration-4-dorfner-v2 阅读 27 收藏 0 点赞 0 评论 0
@Test
public void successfulInputOfComment() throws IOException {
    String json = "{ plantId: \"58d1c36efb0cac4e15afd278\", comment : \"Here is our comment for this test\" }";

    assertTrue(plantController.addComment(json, "second uploadId"));

    MongoClient mongoClient = new MongoClient();
    MongoDatabase db = mongoClient.getDatabase(databaseName);
    MongoCollection<Document> plants = db.getCollection("plants");

    Document filterDoc = new Document();

    filterDoc.append("_id", new ObjectId("58d1c36efb0cac4e15afd278"));
    filterDoc.append("uploadID", "second uploadId");

    Iterator<Document> iter = plants.find(filterDoc).iterator();

    Document plant = iter.next();
    List<Document> plantComments = (List<Document>) ((Document) plant.get("metadata")).get("comments");
    long comments = plantComments.size();

    assertEquals(1, comments);
    assertEquals("Here is our comment for this test", plantComments.get(0).getString("comment"));
    assertNotNull(plantComments.get(0).getObjectId("_id"));
  }
MongoManager.java 文件源码 项目:rocketmq-flink-plugin 阅读 29 收藏 0 点赞 0 评论 0
public JSONObject executeCount(String dbName, String collectionName, JSONObject reqJson) {

        MongoDatabase db = mongoClient.getDatabase(dbName);
        MongoCollection coll = db.getCollection(collectionName);

        JSONObject resp = new JSONObject();
        Document doc = Document.parse(reqJson.toString());
        long count = coll.count(doc);
        resp.put("Data", count);
        return resp;
    }
InsertDocumentsImpl.java 文件源码 项目:mongodb-crud 阅读 21 收藏 0 点赞 0 评论 0
/**
 * This method insert the more than one document at a time
 */
@Override
public void insertMultipleDocuments() {
    MongoDatabase db = null;
    MongoCollection collection = null;
    try {
        db = client.getDatabase(mongo.getDataBase());
        collection = db.getCollection(mongo.getSampleCollection());

        Document journal = new Document("item", "journal")
                .append("qty", 25).append("tags", asList("blank", "red"));

        Document journalSize = new Document("h", 14).append("w", 21)
                .append("uom", "cm");
        journal.put("size", journalSize);

        Document mat = new Document("item", "mat").append("qty", 85)
                .append("tags", singletonList("gray"));

        Document matSize = new Document("h", 27.9).append("w", 35.5)
                .append("uom", "cm");
        mat.put("size", matSize);

        Document mousePad = new Document("item", "mousePad").append("qty",
                25).append("tags", asList("gel", "blue"));

        Document mousePadSize = new Document("h", 19).append("w", 22.85)
                .append("uom", "cm");
        mousePad.put("size", mousePadSize);
        collection.insertMany(asList(journal, mat, mousePad));
        log.info("Multiple Document Insert Successfully...");
    } catch (MongoException | ClassCastException e) {
        log.error("Exception occurred while insert **Multiple Document** : " + e, e);
    }
}
FlowerControllerSpec.java 文件源码 项目:digital-display-garden-iteration-2-spraguesanborn 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void testUploadFile() {
    String filePath = "/IDPH_STD_Illinois_By_County_By_Sex.xlsx";
    Object object = new Object();
    InputStream excelFile = object.getClass().getResourceAsStream(filePath);

    flowerController.uploadFile(excelFile);

    MongoClient mongoClient = new MongoClient();
    MongoDatabase ddg = mongoClient.getDatabase("ddg");
    MongoCollection flowers = ddg.getCollection("flowers");
    assertEquals(1664, flowers.count());
}
MongoManager.java 文件源码 项目:rocketmq-flink-plugin 阅读 33 收藏 0 点赞 0 评论 0
/**
 * @param dbName         库名
 * @param collectionName 集合名
 * @param json1          条件
 * @param json2          保存doc
 * @return upsert结果信息
 */
public JSONObject executeUpsert(String dbName, String collectionName, JSONObject json1, JSONObject json2) {
    JSONObject resp = new JSONObject();
    try {
        MongoDatabase db = mongoClient.getDatabase(dbName);
        MongoCollection coll = db.getCollection(collectionName);
        JSONObject saveJson = new JSONObject();
        saveJson.put("$set", json2);
        Document doc1 = Document.parse(json1.toString());
        Document doc2 = Document.parse(saveJson.toString());
        UpdateOptions up = new UpdateOptions();
        up.upsert(true);
        UpdateResult ur = coll.updateOne(doc1, doc2, up);
        if (ur.isModifiedCountAvailable()) {
            if (json1.containsKey(ID)) {
                resp.put("Data", json1.get(ID));
            } else {
                resp.put("Data", json1);
            }
        }
    } catch (MongoTimeoutException e1) {
        e1.printStackTrace();
        resp.put("ReasonMessage", e1.getClass() + ":" + e1.getMessage());
        return resp;
    } catch (Exception e) {
        e.printStackTrace();
        resp.put("ReasonMessage", e.getClass() + ":" + e.getMessage());
    }
    return resp;
}
OplogAnalyzer.java 文件源码 项目:oplog-analyzer 阅读 28 收藏 0 点赞 0 评论 0
public void process() {

    MongoDatabase db = mongoClient.getDatabase("local");
    MongoCollection<RawBsonDocument> oplog = db.getCollection("oplog.rs", RawBsonDocument.class);

    RawBsonDocument lastOplogEntry = oplog.find().sort(new Document("$natural", -1)).first();

    BsonTimestamp lastTimestamp = (BsonTimestamp) lastOplogEntry.get("ts");

    System.out.println(lastTimestamp);

    Document query = new Document("ts", new Document("$lt", lastTimestamp));
    for (RawBsonDocument doc : oplog.find(query).noCursorTimeout(true)) {

        BsonString ns = (BsonString) doc.get("ns");
        BsonString op = (BsonString) doc.get("op");

        // ignore no-op
        if (!op.getValue().equals("n")) {
            OplogEntryKey key = new OplogEntryKey(ns.getValue(), op.getValue());
            EntryAccumulator accum = accumulators.get(key);
            if (accum == null) {
                accum = new EntryAccumulator(key);
                accumulators.put(key, accum);
            }
            long len = doc.getByteBuffer().asNIO().array().length;
            accum.addExecution(len);
        }

        if (stop) {
            mongoClient.close();
            report();
            break;
        }
    }
}
DAO.java 文件源码 项目:Babler 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns a MongoCollection based on Model Class
 * @param type Model Class
 * @return MongoCollection for that class
 */
public static MongoCollection getCollectionForClass(Class type) {
    MongoDatabase db = MongoDB.INSTANCE.getDatabase("scraping");
    String collectionName = "";
    if (Tweet.class == type)
        collectionName = "tweets";
    else if (BlogPost.class == type)
        collectionName = "blogPosts";
    else if (ForumPost.class == type)
        collectionName = "forumPosts";

    return db.getCollection(collectionName, BasicDBObject.class);
}
DAO.java 文件源码 项目:Babler 阅读 30 收藏 0 点赞 0 评论 0
/**
 * deletes an entry from the DB
 * @param entry to delete
 */
public static void deleteEntry(DBEntry entry) {
    if(entry == null)
        return;

    MongoDatabase db = MongoDB.INSTANCE.getDatabase("scraping");
    String collectionName = getCollectionName(entry);

    MongoCollection collection = db.getCollection(collectionName, BasicDBObject.class);
    collection.deleteOne(eq("_id",entry.getId()));
}
FlightServiceImpl.java 文件源码 项目:acmeair-modular 阅读 21 收藏 0 点赞 0 评论 0
@PostConstruct
public void initialization() {
    MongoDatabase database = ConnectionManager.getConnectionManager().getDB();
    flight = database.getCollection("flight");
    flightSegment = database.getCollection("flightSegment");
    airportCodeMapping = database.getCollection("airportCodeMapping");
}
StoreInMongoIT.java 文件源码 项目:nifi-nars 阅读 23 收藏 0 点赞 0 评论 0
@After
public void tearDown() throws Exception {
    if (null != mongo) {
        MongoClient client = mongo.getMongoClient();
        if (client != null) {
            MongoDatabase db = client.getDatabase(MONGO_DATABASE_NAME);
            if (db != null) {
                db.drop();
            }
            client.close();
        }
    }
}
UpdateMongoIT.java 文件源码 项目:nifi-nars 阅读 26 收藏 0 点赞 0 评论 0
@After
public void tearDown() throws Exception {
    if (null != mongo) {
        MongoClient client = mongo.getMongoClient();
        MongoDatabase db = client.getDatabase(MONGO_DATABASE_NAME);
        if (db != null) {
            db.drop();
        }
        client.close();
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号