I have the following code, which queries a MySQL database to check if the user is an administrator or not.
public String admin ()
{
String username = loginUserTF.getText();
String password = loginPassPF.getText();
String query = "SELECT * FROM userinfo where username=? and password=?";
try {
connect.pst = connect.con.prepareStatement(query);
connect.pst.setString(1, username);
connect.pst.setString(2, password);
connect.rs = connect.pst.executeQuery();
String admin = connect.rs.getString("Administrator");
return admin;
} catch(Exception e){}
}
I know that the return statement has to be outside the try and catch block but then I am not able to return the String admin. What is a way around this?
Exception, by the way - catch a more specific exception, e.g.SQLException.)