public static void main(String[] args) {
 
	try {
 
		Mongo mongo = new Mongo("localhost", 27017);
		DB db = mongo.getDB("yourdb");
 
		// get a single collection
		DBCollection collection = db.getCollection("dummyColl");
 
		logger.debug("Testing 1...");
		insertDummyDocuments(collection);
		//find hosting = hostB, and update it with new document
		BasicDBObject newDocument = new BasicDBObject();
		newDocument.put("hosting", "hostB");
		newDocument.put("type", "shared host");
		newDocument.put("clients", 111);
 
		collection.update(new BasicDBObject().append("hosting", "hostB"), newDocument);
 
		printAllDocuments(collection);
		removeAllDocuments(collection);
 
		logger.debug("Testing 2...");
		insertDummyDocuments(collection);
		//find hosting = hostB and increase its "clients" value by 99
		BasicDBObject newDocument2 = new BasicDBObject().append("$inc", 
				new BasicDBObject().append("clients", 99));
 
		collection.update(new BasicDBObject().append("hosting", "hostB"), newDocument2);
 
		printAllDocuments(collection);
		removeAllDocuments(collection);
 
		logger.debug("Testing 3...");
		insertDummyDocuments(collection);
		//find hosting = hostA and update type to from "vps" to "dedicated server"
		BasicDBObject newDocument3 = new BasicDBObject().append("$set", 
				new BasicDBObject().append("type", "dedicated server"));
 
		collection.update(new BasicDBObject().append("hosting", "hostA"), newDocument3);
		printAllDocuments(collection);
		removeAllDocuments(collection);
 
		logger.debug("Testing 4...");
		insertDummyDocuments(collection);
		//find type = vps , update all matched documents , clients value to 888
		BasicDBObject updateQuery = new BasicDBObject().append("$set", 
				new BasicDBObject().append("clients", "888"));
 
		//both method are same
		//collection.updateMulti(new BasicDBObject().append("type", "vps"), updateQuery);
 
		collection.update(
                        new BasicDBObject().append("type", "vps"), updateQuery, false, true);
 
		printAllDocuments(collection);
		removeAllDocuments(collection);
 
		logger.debug("Done");
 
	} catch (UnknownHostException e) {
		e.printStackTrace();
	} catch (MongoException e) {
		e.printStackTrace();
	}
 
    }