Insérer une colonne dans un JTable
Bonjour,
Je voudrai afficher une colonne (que je calcule après l'avoir récupérer de ma bdd)dans un jtable lorsque je clique sur un bouton OK
Merci de m'aider
Mon code est le suivant:
Code:
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
int somme=0;
ConnectionDB conn = null;
conn = new ConnectionDB("jdbc:mysql://localhost/mysql");
conn.executeUpdate("CREATE DATABASE IF NOT EXISTS one");
conn = new ConnectionDB("jdbc:mysql://localhost/one");
ResultSet rs = conn.executeQuery("SELECT Prev12, Prev13, Retard, Cons12, Stock, Qte, Qte1 FROM feuil3 ");
int j=1;
while (rs.next()){
int prev1=rs.getInt("Prev12");
int prev2=rs.getInt("Prev13");
int ret=rs.getInt("Retard");
int cons=rs.getInt("Cons12");
int Qt=rs.getInt("Qte");
int Qt1=rs.getInt("Qte1");
int stk=rs.getInt("Stock");
somme=((prev1+prev2+ret-cons)-(Qt+Qt1+stk));
// String s=String.valueOf(somme);
// System.out.println("somme est:"+somme);
jTable1.setValueAt(somme,j,1);
j++;
}
} catch (Exception ex) {
Logger.getLogger(page2.class.getName()).log(Level.SEVERE, null, ex);
}
} |