I'm using JDBC to check a database for a username and password to grant login access to my gui, but when I'm trying to test that the JDBC is working its not blocking access when the wrong username and password is entered..
Below is my code, I believe its connecting the the database correctly, as when i press the login button it outputs Running Check Login and User is validated.
Your checkLogin()
method returns true if everything is OK, and false otherwise. But you don't check the result of the method in your UI, and thus proceed even if it returned false.
The code should do
try {
boolean loggedIn = usernamecheck.checkLogin(jtfUsername.getText(), jtfPassword.getText());
if (!loggedIn) {
displayErrorMessage("Sorry, wrong credentials");
return;
}
}
catch (SQLException se) {
e.printStackTrace();
displayErrorMessage("Sorry, couldn't check your credentials. Check the logs and report the problem to an administrator.");
return;
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments