Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void deleteRow() {
- actionListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- try {
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/computer_inventory","root","");
- PreparedStatement pstate = con.prepareStatement("DELETE FROM sales WHERE ProductName=(SELECT MAX(ProductName) FROM sales)");
- pstate.executeUpdate();
- JOptionPane.showMessageDialog(null,"Successfully Deleted");
- con.close();
- }catch(SQLException ex) {
- ex.printStackTrace();
- JOptionPane.showMessageDialog(null,"Error");
- }
- }
- };
- view.deleteData().addActionListener(actionListener);
- } }
Add Comment
Please, Sign In to add comment