Java Code Examples for com.mongodb.DBCollection#drop()

The following examples show how to use com.mongodb.DBCollection#drop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RootController.java    From hcp-cloud-foundry-tutorials with Apache License 2.0 5 votes vote down vote up
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody Result onRootAccess() {

    DBCollection collection = mongoTemplate.getCollection("test");
    long count = collection.getCount();
    log.info("Object count in 'test' collection before insert: " + count + "<br/> Inserting one object.<br/>");

    BasicDBObject dBObject = new BasicDBObject();
    dBObject.put("hello", "world");
    collection.insert(dBObject);
    count = collection.count();
    log.info("Object count in test collection after insert:" + count);

    Result result = new Result();
    List<DBObject> dbObjects = new ArrayList<DBObject>();
    DBCursor cursor = collection.find();
    while (cursor.hasNext()) {
        com.mongodb.DBObject obj = cursor.next();
        final String value = (String) obj.get("hello");
        DBObject object = new DBObject();
        object.setKey("hello");
        object.setValue(value);
        dbObjects.add(object);
    }
    result.setDbObjects(dbObjects);
    result.setStatus(
            "Successfully accessed Mongodb service. Retrieving the data object inserted in test collection.");
    collection.drop();
    return result;
}
 
Example 2
Source File: MongoUtil.java    From gameserver with Apache License 2.0 5 votes vote down vote up
/**
 * Drop the given collection from database.
 * @param databaseName
 * @param namespace
 * @param collection
 */
public static final void dropCollection(String databaseName,
		String namespace, String collection ) {
	
	DBCollection coll = getDBCollection(databaseName, namespace, collection);
	coll.drop();
}
 
Example 3
Source File: MongoDBUtil.java    From gameserver with Apache License 2.0 5 votes vote down vote up
/**
 * Drop the given collection from database.
 * @param databaseName
 * @param namespace
 * @param collection
 */
public static final void dropCollection(String databaseName,
		String namespace, String collection ) {
	
	DBCollection coll = getDBCollection(databaseName, namespace, collection);
	coll.drop();
}
 
Example 4
Source File: MongoJobFeedbackQueue.java    From light-task-scheduler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean removeQueue(String jobClientNodeGroup) {
    String tableName = JobQueueUtils.getFeedbackQueueName(jobClientNodeGroup);
    DBCollection dbCollection = template.getCollection(tableName);
    dbCollection.drop();
    LOGGER.info("drop queue " + tableName);
    return true;
}
 
Example 5
Source File: MongoExecutableJobQueue.java    From light-task-scheduler with Apache License 2.0 5 votes vote down vote up
@Override
public boolean removeQueue(String taskTrackerNodeGroup) {
    String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
    DBCollection dbCollection = template.getCollection(tableName);
    dbCollection.drop();
    LOGGER.info("drop queue " + tableName);

    return true;
}