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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| rivate void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String nomOutil = JTNomOutil.getText();
String fabricantOutil = JTFabricantOutil.getText();
String anneeFabrication = JTAnneeFabrication.getText();
String prix = JTPrix.getText();
int ligneSelectionne = TableOutil.getSelectedRow();
String outil = TableOutil.getValueAt(ligneSelectionne, 0).toString();
PreparedStatement stmt = null;
String wql = "update outil Set nom_outil,fabricant_outil,annee_fabrication,prix_outil = ? where id_outil = ?";
try {
JOptionPane jop = new JOptionPane();
String nom = (String)JOptionPane.showInputDialog(
null,
"Veuillez entrer votre modification",
"Modification",
JOptionPane.QUESTION_MESSAGE,
new ImageIcon(
getClass().getResource("arbre.gif")),
stmt.setString(1, "");
stmt.setString(2, "id_outil");
stmt.executeUpdate();
JOptionPane.showMessageDialog(mainFrame, "Votre requête a été exécuté" );
JTNomOutil.setText("");
JTFabricantOutil.setText("");
JTAnneeFabrication.setText("");
JTPrix.setText("");
maconnexion.commit();
} catch (SQLException e ) {
Connexion.printSQLException(e);
if (maconnexion != null) {
try {
System.err.print("Transaction is being rolled back");
maconnexion.rollback();
} catch(SQLException excep) {
Connexion.printSQLException(excep);
}
}
} finally {
if (stmt != null) {
try{
stmt.close();
}
catch(SQLException excep) {
Connexion.printSQLException(excep);
}
}
try{
maconnexion.setAutoCommit(true);
}
catch(SQLException excep) {
Connexion.printSQLException(excep);
}
}
} |