java中的mongoDB怎么分页,要代码,数据量较大
1个回答
展开全部
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());
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());
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询