Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Add Comment
Please, Sign In to add comment