import java.net.UnknownHostException;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
public class DeleteData {
/**
* @param args
* @throws UnknownHostException
*/
public static void main(String[] args) throws UnknownHostException {
Mongo mongo=new Mongo("127.0.0.1",27017);//链接mongoDB
DB db=mongo.getDB("my");//获取my数据库
DBCollection collection=db.getCollection("t");//获取t集合
DBObject object=new BasicDBObject();
object.put("id", 1);
//删除id为1的文档
collection.remove(object);
}
}