Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void actionPerformed(ActionEvent arg0) {
- try{
- String query = "select * from usernames where username=? and password=?";
- PreparedStatement pst = dataConnection.prepareStatement(query);
- pst.setString(1, textField_1.getText() );
- pst.setString(2, passwordField.getText() );
- ResultSet rs = pst.executeQuery();
- int count = 0;
- while (rs.next())
- {
- count++;
- }
- if(count == 1)
- {
- JOptionPane.showMessageDialog(null, "Login Successful, proceeding to functions list.");
- dataConnection.close();
- MainWindow.initializemain();
- frmConsoleappReborn.setVisible(false);
- }
- else if (count > 1)
- {
- JOptionPane.showMessageDialog(null, "Contact developer and tell them the database is has duplicate values.");
- }
- else {
- JOptionPane.showMessageDialog(null, "Username or password is incorrect. Please try again.");
- }
- } catch(Exception e) {
- JOptionPane.showMessageDialog(null, e);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement