X-Received: by 10.182.111.227 with SMTP id il3mr13425325obb.41.1392740741874; Tue, 18 Feb 2014 08:25:41 -0800 (PST) X-Received: by 10.50.30.66 with SMTP id q2mr421243igh.1.1392740741752; Tue, 18 Feb 2014 08:25:41 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!xmission!news.glorb.com!uq10no27958140igb.0!news-out.google.com!h8ni12igy.0!nntp.google.com!uq10no27958137igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Tue, 18 Feb 2014 08:25:41 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=203.91.213.69; posting-account=jTfW2goAAAAQ22MIGwAE2QBL_Qjp5rLZ NNTP-Posting-Host: 203.91.213.69 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7e697752-e40a-42a1-b96d-3f37fc37dbed@googlegroups.com> Subject: while loop is not working properly why From: Navneet Mathpal Injection-Date: Tue, 18 Feb 2014 16:25:41 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:27546 cursor is not going inside the while why?? public void fetch_data() throws Exception { Mongo mongo = new Mongo("localhost", 27017); DB db = mongo.getDB("relevancy_data"); DBCollection collection = db.getCollection("relevancy"); BasicDBObject andQuery = new BasicDBObject(); List obj = new ArrayList(); obj.add(new BasicDBObject("Platform","ElasticSearch")); obj.add(new BasicDBObject("Enviroment", "Developer")); obj.add(new BasicDBObject("Test_name", "Search_apple")); andQuery.put("$and", obj); System.out.println(obj.size()); //System.out.println(andQuery.toString()); DBCursor cursor = collection.find(andQuery); while (cursor.hasNext()) { System.out.println("inside of while"); System.out.println(cursor.next()); } System.out.println("outside of while"); }