首页 > 解决方案 > 为什么我的数据库没有更新?(使用netbeans xampp mysql)

问题描述

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

 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();}   

        }
    }   

这是我的数据库,表名是 tblproductssales

标签: mysqldatabasenetbeansxampp

解决方案


推荐阅读