j'ai besoin d'effectuer quelques statistiques sur ma base de données sur un JTable, donc j'ai prévu de construire un array d'objects
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 DefaultTableModel model = new DefaultTableModel(); // // model.addColumn("Filières"); model.addColumn("Nbr Garçons"); model.addColumn("Nbr Filles"); // // public void tableFill(){ String query = "SELECT filiere FROM filiere"; Object[] rowData = null; try (PreparedStatement stat = cnx.prepareStatement(query)){ rslt = stat.executeQuery(); while(rslt.next()){ String fil = rslt.getString("filiere"); //countM() fonction qui calcule les garçons dans cette fillière String mCount = String.valueOf(countM(rslt.getString("filiere"))); //countF() fonction qui calcule les filles dans cette fillière String fCount = String.valueOf(countF(rslt.getString("filiere"))); //ici erreur ???? rowData = new Object[fil,mCount,fCount]; model.addRow(rowData); } } catch (Exception e) { e.printStackTrace(); } }
Partager