Guest User

Untitled

a guest
Sep 10th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.sql.*;
  2. public class database
  3. {
  4. Connection con;
  5. PreparedStatement pst;
  6. ResultSet rs;
  7. database()
  8. {
  9. try{
  10.  
  11. Class.forName("com.mysql.jdbc.Driver");
  12. con=DriverManager.getConnection("jdbc:mysql://localhost/dbziy", "root", "");
  13. pst=con.prepareStatement("select * from karyawan where Username=? and Password=?");
  14.  
  15. }
  16. catch (Exception e)
  17. {
  18. System.out.println(e);
  19. }
  20. }
  21.  
  22. public Boolean checkLogin(String cb,String Password)
  23. {
  24. try {
  25.  
  26. pst.setString(1, cb);
  27. pst.setString(2, Password);
  28.  
  29. rs=pst.executeQuery();
  30. if(rs.next())
  31. {
  32. return true;
  33. }
  34. else
  35. {
  36. return false;
  37. }
  38. } catch (Exception e) {
  39. // TODO Auto-generated catch block
  40. System.out.println("error while validating"+e);
  41. return false;
  42. }
  43. }
  44. }
Add Comment
Please, Sign In to add comment