I'm searching in the database for the URL but with this code I can not. Why? Normally I want to print all the type and the URL where exist in this database. When I have the print only with the type is working but with the print for URL nothing.
MongoClient mongoClient;
DB db;
mongoClient = new MongoClient("localhost", 27017);
db = mongoClient.getDB("behaviourDB_areas");
DBCollection cEvent = db.getCollection("event");
BasicDBObject orderBy = new BasicDBObject();
orderBy.put("timeStamp",1);
DBCursor cursorEvents = null;
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.put("user_id", "55b20db905f333defea9827f");
cursorEvents = cEvent.find(searchQuery).sort(orderBy);
int count=0;
if(cursorEvents.hasNext()){
while(cursorEvents.hasNext()){
count++;
System.out.println(cursorEvents.next().get("type").toString());
System.out.println(cursorEvents.next().get("url").toString());
System.out.println(count);
}
}
mongoClient.close();
}
}