3
How do I check if a database field is filled or null? Do you have a Resultset method that does this check?
In this case it is a date field.
PreparedStatement ps = connection.prepareStatement("SELECT * FROM tarefas");
ResultSet result = ps.executeQuery();
while(result.next()) {
Tarefa tarefa = new Tarefa();
tarefa.setId(result.getLong(1));
tarefa.setDescricao(result.getString(2));
tarefa.setFinalizado(result.getBoolean(3));
if(quero fazer a verificação aqui) {
Calendar calendario = Calendar.getInstance();
calendario.setTime(result.getDate(4));//Ainda não sei se isso funciona
tarefa.setDataFinalizacao(calendario);
}
lista.add(tarefa);
}
I don’t know what I did wrong that I think I tried the first one, and it didn’t work out, now with your help it was.
– user89736
@Welsonteles can sometimes be that it confused something or had not recompiled, but how good that solved.
– Guilherme Nascimento
as to the second solution would not suit me, since I want to take all the lines, just could not treat the null fields, Valew
– user89736