Exceiption in MongoDB

瀏覽次數:41 次
跳到第一則未讀訊息

prem kumar

未讀,
2012年11月11日 下午3:20:502012/11/11
收件者: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
訊息已遭刪除

Rob Moore

未讀,
2012年11月11日 下午4:56:122012/11/11
收件者: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.
回覆所有人
回覆作者
轉寄
0 則新訊息