Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #27547

Re: while loop is not working properly why

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx26.iad.POSTED!not-for-mail
From Daniel Pitts <newsgroup.nospam@virtualinfinity.net>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: while loop is not working properly why
References <7e697752-e40a-42a1-b96d-3f37fc37dbed@googlegroups.com>
In-Reply-To <7e697752-e40a-42a1-b96d-3f37fc37dbed@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Lines 37
Message-ID <dfNMu.319747$Z94.260283@fx26.iad> (permalink)
X-Complaints-To abuse@newsrazor.net
NNTP-Posting-Date Tue, 18 Feb 2014 18:02:49 UTC
Date Tue, 18 Feb 2014 10:02:49 -0800
X-Received-Bytes 1831
X-Received-Body-CRC 4195863240
Xref csiph.com comp.lang.java.programmer:27547

Show key headers only | View raw


On 2/18/14 8:25 AM, Navneet Mathpal wrote:
>
>
>
> 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<BasicDBObject> obj = new ArrayList<BasicDBObject>();
> 	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");
> 	
> 	
> 	}
>

The while loop is working properly.  My guess is that cursor.hasNext() 
returns false.

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

while loop is not working properly why Navneet Mathpal <navneetmathpal93@gmail.com> - 2014-02-18 08:25 -0800
  Re: while loop is not working properly why Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2014-02-18 10:02 -0800
  Re: while loop is not working properly why Roedy Green <see_website@mindprod.com.invalid> - 2014-02-18 15:13 -0800

csiph-web