码迷,mamicode.com
首页 > 数据库 > 详细

com.mongodb.MongoException$CursorNotFound: cursor not found on server异常处理

时间:2015-06-11 16:57:02      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

java链接MongoDB处理大量数据时经常碰到cursor not found 的异常,其实是超时所致


Exception in thread "main" com.mongodb.MongoException$CursorNotFound: cursor not found on server
        at com.mongodb.DBApiLayer$Result.init(DBApiLayer.java:379)
        at com.mongodb.DBApiLayer$Result._advance(DBApiLayer.java:426)
        at com.mongodb.DBApiLayer$Result.hasNext(DBApiLayer.java:408)
        at com.mongodb.DBCursor._hasNext(DBCursor.java:495)
        at com.mongodb.DBCursor.hasNext(DBCursor.java:515)


在国内论坛上转了一圈,解决方法说的不知所云,其实解决方法很简单:
            DBCursor cursor = collection.find(condtion);
                 cursor.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT);

只要在查询的DBCursor添加com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT就解决!

com.mongodb.MongoException$CursorNotFound: cursor not found on server异常处理

标签:

原文地址:http://blog.csdn.net/odailidong/article/details/46458349

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!