1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public Vector afficher(..........) throws RemoteException {
.
.
.
.
Vector<Vector<String>> datatable = new Vector<Vector<String>>();
//*************************************************
try {
Statement stmt = conn.createStatement();
resultats = stmt.executeQuery(req);
} catch (SQLException e) {
System.err.println(e.getMessage());//"Anomalie lors de l'execution de la requete");
}
//parcours des données retournees
try {
ResultSetMetaData rsmd = resultats.getMetaData();
int nbCols = rsmd.getColumnCount();
boolean encore = resultats.next();
datatable.add(null);
while (encore) {
Vector<String> ligne = new Vector<String>();//ligne de datatable
for (int i = 1; i <= nbCols; i++){
ligne.add(resultats.getString(i)); //cellule de la ligne
}
datatable.add(ligne);
encore = resultats.next();
}
resultats.close();
} catch (SQLException e) {
System.err.println(e.getMessage());
}
return datatable;
} |