Delete Data with help of jtable rows. we can get table row 0-postion field value.


 try
        {
        int row=clear.getSelectedRow();
        String t=(clear.getValueAt(row, 0).toString());
         Class.forName("com.mysql.jdbc.Driver");
            java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/lms","root","root");
            String sql="delete from clearpayment where ID='"+t+"'";
            PreparedStatement pst=con.prepareStatement(sql);
            pst.executeUpdate();
            JOptionPane.showMessageDialog(null,"Deleted!!!");
        }
        catch(Exception e)
        {
        JOptionPane.showMessageDialog(null,"Click on Table!!!");
        }
        clear();

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.