NWall
NWall

Reputation: 13

JDBC returning a result set

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

Answers (2)

shepard23
shepard23

Reputation: 198

Select email, playerpassword FROM players WHERE email = ?

Upvotes: 0

singhakash
singhakash

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

Related Questions