MongoClient mongo = new MongoClient("localhost", 27017); DB db = mongo.getDB("airlinedb"); DBCollection collection = db.getCollection("airlinefinal"); BasicDBObject searchQuery = new BasicDBObject("ORIGIN","JFK"); BasicDBObject fields = new BasicDBObject(); fields.put("ORIGIN",1); fields.put("DEST", 1); fields.put("_id", 0); DBCursor cursor = collection.find(searchQuery,fields); @SuppressWarnings("unused") List<DBObject> myList = new ArrayList<DBObject>(); myList = cursor.toArray(); String[] columnNames = {"Origin", "Destination"}; DefaultTableModel model = new DefaultTableModel(MyList, columnNames); table = new JTable(model);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)