bonjour tout le monde,
je developpe une app de gestion de stock en java sous netbeans et lors de la modification des enregistrements sur le bouton MODIFIER j'ai cette erreur
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Erreur de syntaxe près de '' WHERE ref_prod= 22' à la ligne 1
aidez moi SVP !!
voici le code du bouton modifier:
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
33
34
Connection conn =null;
    Statement stm = null;
    ResultSet rsss = null;
        try { 
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/gs_cfa?useUnicode=true&characterEncoding=utf8","root","");
            stm = conn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(PRODUIT.class.getName()).log(Level.SEVERE, null, ex);
        }
 
        try {
             if (JOptionPane.showConfirmDialog(null, "etes vous sure ?",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
            stm.executeUpdate("UPDATE produit SET "
                    + "num_bl='" + nbl.getText() + "',"
                    + "ref_prod='" + nump.getText() + "',"
                    + "codebare='" + barecode.getText() + "',"
                    + "designation='" + nomp.getText() + "',"
                    + "designation_fr='" + nomp_fr.getText() + "',"
                    + "categorie='" + catp.getSelectedItem().toString() + "',"
                    + "unite_p='" + unitep.getSelectedItem().toString() + "',"
                    + "type='" + typep.getSelectedItem().toString() + "',"
                    + "quantite_T='" + qtep.getText() + "',"
                    + "prix_unitaire='" + prixp.getText()+ "',"
                    + "date_exp='" + datexp.getDate()+ "',"
                    + "alerte_q='"+ alerteq.getText()+ "',"
                    + "alerte_d='"+ alerted.getText()+ "',"
                    + "' WHERE ref_prod= " + nump.getText());
              afficher();
        }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "erreur de modification !!!!!!!" + e.getMessage());
            System.err.println(e);
        }
void afficher ()
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
 private void afficher() {
        try {
            model.setRowCount(0);
            st = con.createStatement();
            rs = st.executeQuery("Select num_bl,ref_prod,codebare,designation,designation_fr,categorie,unite_p,type,date_exp,quantite_T,prix_unitaire,alerte_q,alerte_d from produit ");
            while (rs.next()) {
                model.addRow(new Object[]{
                    //rs.getString("id_prod"), 
                    rs.getString("num_bl"),
                    rs.getString("ref_prod"), 
                    rs.getString("codebare"),
                    rs.getString("designation"),
                    rs.getString("designation_fr"),
                    rs.getString("categorie"), 
                    rs.getString("unite_p"),
                    rs.getString("type"),
                    rs.getString("quantite_T"),
                    rs.getString("prix_unitaire"),
                    rs.getString("date_exp"),
                    rs.getString("alerte_q"), 
                    rs.getString("alerte_d") });
 
 
            }
        } catch (Exception e) {
            System.err.println(e);
        }
 
        tbl_prod1.setModel(model);
        //tbl_prod1.setDefaultRenderer(Object.class, new MyTableRenderer1()); 
    }