Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. String username = usernameText.getText();
  2. char[] passwrd = passwordField.getPassword();
  3. String password = new String(passwrd);
  4. boolean blnFound = false;
  5.  
  6. statement.executeQuery("SELECT username, password FROM users WHERE username='" + username + "' " +
  7. "AND password='" + password + "';");
  8. ResultSet rs = statement.getResultSet();
  9. blnFound = rs.first();
  10.  
  11. System.out.println("blnFound. Closing log in window.n");
  12.  
  13. // close login window upon pressing enter
  14. dispose();
  15.  
  16. int i = 0;
  17.  
  18. while (i < 3) {
  19. if (blnFound) {
  20.  
  21. if (username == "admin") {
  22. //pass along value of username
  23. //add admin class
  24. } else {
  25. //regular user
  26. //pass along value of username
  27.  
  28. newTicket nw = new newTicket();
  29. nw.username(username);
  30.  
  31. java.awt.EventQueue.invokeLater(new Runnable() {
  32. public void run() {
  33. new user().setVisible(true);
  34. }
  35. });
  36. }
  37. } else { //incorrect password code
  38. i++;
  39.  
  40. String message = "Username or password incorrect."
  41. + "nn" + "You have used " + i + " out of 3 tries.";
  42. System.out.println("Show Dialog.");
  43. JOptionPane.showMessageDialog(null, message);
  44. System.out.println("Restart login.");
  45.  
  46. java.awt.EventQueue.invokeLater(new Runnable() {
  47. public void run() {
  48. new logIn().setVisible(true);
  49. }
  50. });
  51. }
  52. }
  53.  
  54. if (i == 3) {
  55. String end = "You have attempted too many times.";
  56. JOptionPane.showMessageDialog(null,end);
  57. System.exit(0);
  58. }
  59.  
  60. statement.close();
  61. connect.close();
  62.  
  63. } catch (Exception e1) {
  64. System.out.println(e1.getMessage());
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement