Guest User

Untitled

a guest
Oct 10th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public void deleteRow() {
  2. actionListener = new ActionListener() {
  3. public void actionPerformed(ActionEvent actionEvent) {
  4. try {
  5.  
  6. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/computer_inventory","root","");
  7. PreparedStatement pstate = con.prepareStatement("DELETE FROM sales WHERE ProductName=(SELECT MAX(ProductName) FROM sales)");
  8.  
  9. pstate.executeUpdate();
  10. JOptionPane.showMessageDialog(null,"Successfully Deleted");
  11.  
  12. con.close();
  13.  
  14. }catch(SQLException ex) {
  15. ex.printStackTrace();
  16. JOptionPane.showMessageDialog(null,"Error");
  17. }
  18. }
  19.  
  20. };
  21. view.deleteData().addActionListener(actionListener);
  22. } }
Add Comment
Please, Sign In to add comment