Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String username = usernameText.getText();
- char[] passwrd = passwordField.getPassword();
- String password = new String(passwrd);
- boolean blnFound = false;
- statement.executeQuery("SELECT username, password FROM users WHERE username='" + username + "' " +
- "AND password='" + password + "';");
- ResultSet rs = statement.getResultSet();
- blnFound = rs.first();
- System.out.println("blnFound. Closing log in window.n");
- // close login window upon pressing enter
- dispose();
- int i = 0;
- while (i < 3) {
- if (blnFound) {
- if (username == "admin") {
- //pass along value of username
- //add admin class
- } else {
- //regular user
- //pass along value of username
- newTicket nw = new newTicket();
- nw.username(username);
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new user().setVisible(true);
- }
- });
- }
- } else { //incorrect password code
- i++;
- String message = "Username or password incorrect."
- + "nn" + "You have used " + i + " out of 3 tries.";
- System.out.println("Show Dialog.");
- JOptionPane.showMessageDialog(null, message);
- System.out.println("Restart login.");
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new logIn().setVisible(true);
- }
- });
- }
- }
- if (i == 3) {
- String end = "You have attempted too many times.";
- JOptionPane.showMessageDialog(null,end);
- System.exit(0);
- }
- statement.close();
- connect.close();
- } catch (Exception e1) {
- System.out.println(e1.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement