Exceiption in MongoDB

41 views
Skip to first unread message

prem kumar

unread,
Nov 11, 2012, 3:20:50 PM11/11/12
to mongod...@googlegroups.com
Hi,

                       I have one doubt. please reply me.


{ "_id" : { "$oid" : "509b5599aae5057475681319"} , "id" : 1 , "subcatid" : 3001 , "prodid" : 5001 , "prodname" : "Odonil Jasmine" , "path" : "sites/default/files/odonil-
jasmine.jpg" , "merchant-1" : 2}


this is my mongodb answer..I want to take prodid. only using in java.
Example :

              I used a java code that is : String ss = (String)cursor.next.get("prodid");

              It through exceptions.

Exception in thread "main" java.lang.RuntimeException: no more
    at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:387)
    at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:353)
    at com.mongodb.DBCursor._next(DBCursor.java:441)
    at com.mongodb.DBCursor.next(DBCursor.java:521)
    at com.chm.mongo.mongo.ProductMongo1.getCheck1(ProductMongo1.java:62)
    at com.chm.mongo.mongo.ProductMongo1.main(ProductMongo1.java:153)
     
             Anybody help to me.

Thanks,
Prem









           





test.rar
test.txt
Message has been deleted

Rob Moore

unread,
Nov 11, 2012, 4:56:12 PM11/11/12
to mongod...@googlegroups.com

Actually, scratch that. 

The System.out advanced the cursor with a cursor.next() and then you advance it again on the next line with another cursor.next().  You want to save the document in a variable and only call next() once.

Rob.

On Sunday, November 11, 2012 4:53:31 PM UTC-5, Rob Moore wrote:


Your query did not match any documents.  What is the 'name' passed to the method?

Instead of using the cursor.next() without checking if the cursor has a "next()" I would suggest instead using findOne(...).

Rob.
Reply all
Reply to author
Forward
0 new messages