Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public class CpassDao extends ActionSupport {
  2.  
  3. private static final long serialVersionUID = 1L;
  4.  
  5. public static boolean validate(String username,String password,String npass) {
  6. boolean status = false;
  7. ChangePass cp = new ChangePass();
  8.  
  9. try {
  10. Connection con = DBConnection.getConnection();
  11. PreparedStatement ps = con.prepareStatement("select * from doctable where username=? and password=?");
  12.  
  13. ps.setString(1, username);
  14. ps.setString(2, password);
  15.  
  16. ResultSet rs= ps.executeQuery();
  17. status = rs.next();
  18.  
  19. if(true) {
  20. PreparedStatement ps1 = con.prepareStatement("update details set password=? where username=?");
  21. ps1.setString(1, cp.getNpass());
  22. ps1.setString(2, cp.getUsername());
  23. ps1.executeUpdate();
  24. }
  25. }
  26.  
  27. catch (Exception ex) {
  28. ex.printStackTrace();
  29.  
  30. return status;
  31. }
  32.  
  33. return status;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement