java中的mongoDB怎么分页,要代码,数据量较大
发布网友
发布时间:2022-04-22 05:58
我来回答
共1个回答
热心网友
时间:2023-07-14 02:39
List<BasicDBObject> result = new ArrayList<BasicDBObject>();
if (tableName.length() > 0) {
if (cursor == null) {
coll = db.getCollection(tableName);
cursor = coll.find().skip(skipNum).limit(num);
}
while (cursor.hasNext()) {
BasicDBObject o = (BasicDBObject) cursor.next();
result.add(o);
}
}
但是调用出现了问题:
我这样查,
List<BasicDBObject> list1 = mongoDao.queryWithNum(LuceneTest.tableName, 100,100);
List<BasicDBObject> list2 = mongoDao.queryWithNum(LuceneTest.tableName, 200,100);
System.out.print("--结束,共" + list1.size() + "条---" + "--");
System.out.println(list2.size());