jframe bouton modifier:netbeans mysql
bjr, je travail sur une application netbeans java mysql.
Je n'arrive pas à coder le bouton modifier.
à chaque fois c'est la meme erreur qui revient.
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHRERE id='3'' at line 1
SELECT id,code_produit,designation,categorie FROM produits.
voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| private void jBtn_modifierActionPerformed(java.awt.event.ActionEvent evt) {
if(txt_cod.getText().equals("") || txt_desig.getText().equals("") || txt_cat.getText().equals("")){
// || comb_ty.getSelectedItem().equals("typppe")){
JOptionPane.showMessageDialog(this, "SVP entrer les informations complete");
}else{
String[] colon = {"code_produit", "designation", "categorie"};
String[] inf = {txt_cod.getText(),txt_desig.getText(), txt_cat.getText()};
String id = String.valueOf(table_produit.getValueAt(table_produit.getSelectedRow(), 0));
System.out.println(db.queryUpdate(" produits ", colon, inf, "id='" + id + "'"));
table();
Actualiser();
}
} |
voici la function Queryupdate:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public String queryUpdate(String nomTable, String[] nomColonne, String[] contenuTable, String etat){
connectionDatabase();
int i;
SQL = "UPDATE " + nomTable + " SET ";
for(i = 0;i <= nomColonne.length-1; i++){
SQL += nomColonne[i] + "='" + contenuTable[i] + "'";
if(i < nomColonne.length-1){
SQL += ",";
}
}
SQL += " WHRERE " + etat;
return this.executionUpdate(SQL);
} |
la function executionupdate
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| public String executionUpdate(String sql) {
connectionDatabase();
String result = "";
try{
statement = connection.createStatement();
statement.executeUpdate(sql);
result = sql;
}catch(SQLException ex) {
result = ex.toString();
}
return result;
} |
je serai heureux quelqu'un regarde ce code pour moi ou me propose une autre alyetnative
Merci d'avance