I am trying to execute a simple query but i get hilarious error. I really don’t know how to resolve this. Have someone encountered something similar?
PreparedStatement stmt;
if (userId == null) {
stmt = DatabaseConnection.getConnection().prepareStatement(
"UPDATE USERS SET IS_LOGGED = ?");
stmt.setBoolean(1, isLogged);
} else {
stmt = DatabaseConnection.getConnection().prepareStatement(
"UPDATE USERS SET IS_LOGGED = ? WHERE USER_ID = ?");
stmt.setBoolean(1, isLogged);
stmt.setInt(2, userId);
}
CommonInterface.LOGGER.info(stmt.toString());
stmt.executeUpdate();
INFO: prep1022: UPDATE USERS SET IS_LOGGED = ? WHERE USER_ID = ? {1: FALSE, 2: 1}
org.h2.jdbc.JdbcSQLDataException: Parameter "#3" is not set [90012-224]
It happens everytime I try to execute this query, can it be a problem because of not closing the statements?