tableau de statistiques dans JTable
je veux faire des statistiques sur ma BDD en java et avoir le résultat dans un JTable, alors j'ai créé la méthode suivante:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public String getStat(String table, String as, String champ,String condition,String group){
try {
String nbr = "";
String query = "SELECT COUNT(*) FROM "+table+" AS "+as+" WHERE "+champ+"='"+condition+"' GROUP BY "+group;
stat = cnx.prepareStatement(query);
rslt = stat.executeQuery();
if(rslt.next()){
nbr = rslt.getString(as);
}
return nbr;
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
} |
pour visualiser le résultat j'ai dessiné un tableau tableFil, mais je veux que mon tableau affiche pour chaque filière le nombre des filles et garçons
Code:
1 2 3 4 5 6 7 8
|
JButton btnStat = new JButton("Générer Statistiques");
btnStat.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
sql.getStat("etudiant", "Garçons", "genre", "M", "code_f");
tableFil.setModel(DbUtils.resultSetToTableModel(rslt));
}
}); |
mais mon code génère plusieurs erreurs, comme: Column 'genre' not found.
je ne sais comment régler celà :roll: ??