Reputation: 13
I have a database with a few columns for a login screen, I am trying to compare the entered email with the person’s password in the database.
I have the following code, although I keep getting an error saying the column email does not exist, although it does in the database. Any ideas?
public String getPlayerPassword(String emailParameter) throws SQLException {
loadSQlDriver();
String playersEmail = null;
preSTMT = con.prepareStatement("SELECT playerpassword FROM players WHERE email = ?");
preSTMT.setString(1, emailParameter);
rs = preSTMT.executeQuery();
if(rs.next()){
playersEmail = rs.getString("email");
}
return playersEmail;
}
Upvotes: 0
Views: 44
Reputation: 7919
This may be because you dint select email in your query
preSTMT = con.prepareStatement("SELECT playerpassword FROM players WHERE email = ?");
and you are fetching it
playersEmail = rs.getString("email");
Upvotes: 3