zoukankan      html  css  js  c++  java
  • 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)


    解决方法很简单:
               DBCursor cursor = collection.find(condtion);
                    cursor.addOption(com.mongodb.Bytes.QUERYOPTION_NOTIMEOUT);

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

  • 相关阅读:
    2013dgtcs 成绩排序
    JZOJ 1286. 太空电梯
    java单例模式Singleton
    设计模式的类型
    java工厂模式Factory
    Mysql SQL优化
    maven deploy命令打包到私服
    debian/linux 配置maven
    Java RC4加密解密工具
    JedisUtils
  • 原文地址:https://www.cnblogs.com/dailidong/p/7571224.html
Copyright © 2011-2022 走看看