为什么我的数据库没有更新? (使用netbeans xampp mysql)

时间:2018-11-26 20:51:22

标签: mysql database netbeans xampp

当我运行文件时,它接受查询并说更新成功,但是当我检查数据库时为什么不更新?

 private void btnUpdateDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                                
        // TODO add your handling code here:
        if(radioUpdate.isSelected()){

            try{
          Class.forName("com.mysql.jdbc.Driver");
            cn=DriverManager.getConnection("jdbc:mysql://localhost:3306/soften?zeroDateTimeBehavior=convertToNull","root","");
            st=cn.createStatement();
            String sql="UPDATE `tblproductssales` SET "
                    +" product = ?,quantity = ?"
                    +" WHERE 'sale no' = ?";

            PreparedStatement pst = cn.prepareStatement(sql);
            pst.setString(1,editProduct.getText());
            pst.setString(2,editQty.getText());
           pst.setString(3,editSaleID.getText());

            pst.executeUpdate();
            JOptionPane.showMessageDialog(null,"success update");
            //**when i run the file this JOPtionpPane shows
      }catch(Exception e){e.printStackTrace();}   

        }
    }   

here is my database, the table name is tblproductssales

0 个答案:

没有答案