Advertisement
Guest User

Untitled

a guest
Apr 12th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public void actionPerformed(ActionEvent arg0) {
  2. try{
  3. String query = "select * from usernames where username=? and password=?";
  4. PreparedStatement pst = dataConnection.prepareStatement(query);
  5. pst.setString(1, textField_1.getText() );
  6. pst.setString(2, passwordField.getText() );
  7.  
  8. ResultSet rs = pst.executeQuery();
  9. int count = 0;
  10. while (rs.next())
  11. {
  12. count++;
  13. }
  14. if(count == 1)
  15. {
  16. JOptionPane.showMessageDialog(null, "Login Successful, proceeding to functions list.");
  17. dataConnection.close();
  18. MainWindow.initializemain();
  19. frmConsoleappReborn.setVisible(false);
  20. }
  21. else if (count > 1)
  22. {
  23. JOptionPane.showMessageDialog(null, "Contact developer and tell them the database is has duplicate values.");
  24. }
  25. else {
  26. JOptionPane.showMessageDialog(null, "Username or password is incorrect. Please try again.");
  27. }
  28. } catch(Exception e) {
  29. JOptionPane.showMessageDialog(null, e);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement