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


    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)


    解决方法非常easy:
               DBCursor cursor = collection.find(condtion);
                    cursor.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT);

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

  • 相关阅读:
    git 修改文件内容
    centos 7 安装gitlab
    安装Git 创建版本库
    安装 jenkins
    LVS 之搭建
    113. Path Sum II
    112. Path Sum
    111. Minimum Depth of Binary Tree
    110. Balanced Binary Tree
    109.Convert sorted list to BST
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/7123366.html
Copyright © 2020-2023  润新知