Update data in the Database(Java)


  1. Open the last NetBeans project
  2. Add a buttons name it as Update
  3. Double click on buttons and add following codes

    Update

            
              try{
                
                
                String val1=txtID.getText();
                int v1=Integer.parseInt(val1);
                String val2 =txtName.getText();
                String val3=txtAdress.getText();
                            
                   String sql="update EMPDATA set ID='"+v1+"',NAME='"+val2+"',ADRESS='"+val3+"'";
                   pst=conn.prepareStatement(sql);
                   pst.execute();
                   JOptionPane.showMessageDialog(null, "Upadated");
            }      
            catch(Exception e){JOptionPane.showMessageDialog(null, e);}
            

No comments:

Post a Comment