I want to write a resident in my database via java when one of the searched parameters is NULL
, but it turns out I can not figure out how to pass this command.
My code is:
public Usuario registraSaida(String nome) throws SQLException {
String sql = "UPDATE usuario_acesso SET data_saida = ? WHERE usuario_nome = ? AND data_saida = NULL";
java.sql.Timestamp date = new java.sql.Timestamp(new java.util.Date().getTime());
PreparedStatement pst = conexao.prepareStatement(sql);
pst.setTimestamp(1, date);
pst.setString(2, nome);
pst.executeUpdate();
System.out.println(nome);
return null;
}