Guest User

kaur

a guest
Mar 30th, 2018
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. String pass;
  2. user = tf_User.getText();
  3. pass = new String(pf_Pass.getPassword());
  4. try
  5. {
  6. Class.forName("java.sql.Driver");
  7. Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bag_shop","root","root");
  8. Statement stmt = cn.createStatement();
  9. String query = "Select utype from users where uname = '"+user+"' and password = '"+pass+"' ";
  10. ResultSet rs = stmt.executeQuery(query);
  11. if(rs.next())
  12. {
  13. JOptionPane.showMessageDialog(this, "Login Match! \nWelcome Mr. "+user+"\nPress Ok To Proceed!");
  14. utype = rs.getString("utype");
  15. MainForm mf = new MainForm();
  16. mf.show();
  17. this.hide();
  18. }
  19. else
  20. {
  21. i--;
  22. tf_User.setText("");
  23. pf_Pass.setText("");
  24. if(i==0)
  25. {
  26. dispose();
  27. JOptionPane.showMessageDialog(this, "Sorry your 3 chances are over.\nPlease restart program!");
  28. }
  29. else
  30. {
  31. JOptionPane.showMessageDialog(this, "Login Not Match! \nOnly " +i+ " attempt remaining!");
  32. }
  33. }
  34. }
  35. catch(Exception e)
  36. {
  37. JOptionPane.showMessageDialog(this,e);
  38. }
Add Comment
Please, Sign In to add comment