récupération d'un objet dans une variable ou dans un tableau de type String

5 views
Skip to first unread message

yahmadi ahmed

unread,
Apr 25, 2011, 11:17:17 AM4/25/11
to mongodb-user
pour quoi je peux afficher la résultat d'une opération de recherche et
je ne peux pas la stocker dans une variable ou dans un tableau ?

voici mon code :

while(cur1.hasNext())
{


System.out.println("les fichier stockée par l'auteur:
"+ auteur +"sont les suivantes :");


System.out.println( cur1.next().get("nom du
document"));

list_document_auteur.add( cur1.next().get("nom du
document").toString());

}

et voilà la résultat:

correspandance entre les deux fichiers suivantes:
D:\Documents and Settings\yahmadi_ahmed\Bureau\a.txt
Exception in thread "main" java.lang.RuntimeException: no more
at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:347)
at com.mongodb.DBApiLayer$Result.next(DBApiLayer.java:326)
at com.mongodb.DBCursor._next(DBCursor.java:332)
at com.mongodb.DBCursor.next(DBCursor.java:410)
at Stocker.recherche_correspondance(Stocker.java:162)
at Stocker.main(Stocker.java:206)

sachant que list_document est déclarer comme suit :
public ArrayList<Object> list_document_auteur = new
ArrayList<Object>();


Donc est ce qu'il y a une personne qui peut m'aider à résoudre ce
problème.

Kyle Banker

unread,
Apr 25, 2011, 12:13:14 PM4/25/11
to mongod...@googlegroups.com
Quand on invoque "next()", on avance le cursor. Donc ne doit invoquer
"next()" q'une fois par document:

http://pastie.org/1831857

2011/4/25 yahmadi ahmed <yahmadi....@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages