I am getting following error when I try to get ResultSet:
relation "user_login" does not exist Position: 22
I have a table name User_Login but the error indicates lower case table name. I have been trying to debug it but I am unable to find out the root cause. Below is my code snippet. Please take a look.
public String execute() throws SQLException {
String returnPage = "ERROR";
Connection connection = null;
try {
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/Dislocation", "user","pass");
String sql = "SELECT username FROM User_Login WHERE";
sql+=" username = ? AND password = ?";
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, this.getUsername());
stmt.setString(2, this.getPassword());
ResultSet resultSet = stmt.executeQuery(); // causing error
while (resultSet.next()) {
this.username = resultSet.getString(1);
this.password = resultSet.getString(2);
returnPage = "SUCCESS";
}
} catch (ClassNotFoundException ex) {
returnPage = "ERROR";
ex.getMessage();
} finally {
if (connection != null) {
connection.close();
}
}
return returnPage;
}
stack trace:
org.postgresql.util.PSQLException: ERROR: relation "user_login" does not exist Position: 22