成功连接到MongoDB数据库后,我在尝试通过DBCursor时收到此异常:
Exception in thread "main" com.mongodb.MongoInternalException: couldn't get next element
at com.mongodb.DBCursor.hasNext(DBCursor.java:448)
这是代码,while条件的行是引发异常的行:
DBCollection upages = db.getCollection("upages");
DBCursor pageviewedbyuser = upages.find();
while (pageviewedbyuser.hasNext()) {
etc etc
}
从Mongo shell访问upages
集合时,似乎很清楚它不是空的。 DBCursor
似乎已成功加载,因为错误日志中有这一行:
SEVERE: MyPort.error called
java.io.IOException: finished reading objects but still have: 19553 bytes to read!'
以前是否有人遇到此错误?有什么想法吗?