[Please Help] java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
The coding below is just a simple login system, it checks whether the data in database (Access) is the same as what the user inserted via the JTextFields.
However, I'm having troubles when the data is incorrect, theoritically, as you can see by the program, a JOptionPane should popup & say incorrect, but alas, only a exception appears:
String user = myuser.getText ();
String pass = mypass.getText ();
String sql = "SELECT COUNT(*) FROM LOGIN WHERE Username = '" + user + "' AND Password = '" + pass + "';";
rs = stmt.executeQuery (sql);
int count = rs.getInt (1);
if (count == 1)
JOptionPane.showMessageDialog (null, "Incorrect. Please retry or contact a game manager.");
catch (Exception e)
System.out.println ("Mybtn1 has encountered a error:");
Does anybody know what's wrong with the coding / could enlighten aything?
Thanks in advance