Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String username=jTextField1.getText();
- String password=jPasswordField1.getText();
- String new_pass=jPasswordField2.getText();
- update(1,username,new_pass);
- }
- public void update(int id, String name, String pass) {
- int i = 0;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/database", "root", "");
- String sql = "UPDATE user_pass SET id=?, password=? WHERE username=? ";
- PreparedStatement pst = con.prepareStatement(sql);
- pst.setInt(1, id);
- System.out.println("Yeha samma thik xa");
- pst.setString(2, name);
- pst.setString(3, pass);
- pst.executeUpdate();
- System.out.println("Updated Successifully");
- JOptionPane.showMessageDialog(null, "Successifully updated! ");
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(null, "Sorry there is an errornPlease check the information provided ", " ", JOptionPane.ERROR_MESSAGE);
- }
- }
- catch (Exception ex) {
- JOptionPane.showMessageDialog(null, "Sorry there is an errornPlease check the information provided ", " ", JOptionPane.ERROR_MESSAGE);
- }
- String sql=UPDATE user_pass SET id='"+id+"', password='"+password+"' WHERE username='"+username+"' ";
- } catch (Exception ex) {
Add Comment
Please, Sign In to add comment