static void printAll(MongoCursor<Student> cursor) { try { System.out.println("----------- printAll -------------"); while (cursor.hasNext()) { Student doc = cursor .next(); // извлекаем текущий документ и перемещаем курсор к следующему документу в // наборе System.out.println( "_id: " + doc.getId() + ", name: " + doc.getName() + ", gruppa: " + doc.getGruppa()); // (new StudentData(cursor.getInt("id"), cursor.getString("name"), // cursor.getString("gruppa"))); } } finally { System.out.println("----------- ******** -------------"); try { cursor.close(); } catch (Exception e) { e.printStackTrace(); } } }
static void printOne(Student doc) { System.out.println( "_id: " + doc.getId() + ", name: " + doc.getName() + ", gruppa: " + doc.getGruppa()); System.out.println("----------- ******** -------------"); }