为什么删除jframe java中的按钮错误

时间:2017-08-14 01:24:58

标签: java jframe

我在youtube上试过教程 我在jframe java中创建了删除按钮,然后当我运行错误时

 private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {                                          
   if (!jtextId.getText().equals(""))
   {
       try {
           Connection con = getConnection();
           PreparedStatement ps = con.prepareStatement("DELETE FROM product WHRRE id = ?");
           int id=Integer.parseInt(jtextId.getText());
           ps.setInt(1, id);
           ps.executeUpdate();
           JOptionPane.showMessageDialog(null, "Data Delete");

       } catch (SQLException ex) {
           Logger.getLogger(Main_Window.class.getName()).log(Level.SEVERE, null, ex);
           JOptionPane.showMessageDialog(null, "Produt Not Deleted");
       }

   }
   else{
       JOptionPane.showMessageDialog(null, "Enter Product");
   }
}                                         

输出错误位于ps.executeUpdate();

我应该修理什么?

1 个答案:

答案 0 :(得分:3)

如果您粘贴的代码是实际代码,则错误来自此行:

PreparedStatement ps = con.prepareStatement("DELETE FROM product WHRRE id = ?");

您的SQL中有拼写错误,请替换为:

PreparedStatement ps = con.prepareStatement("DELETE FROM product WHERE id = ?");