estou tentando atualizar o meu objeto só que não consigo.
Atualizar
public void atualizaTarefa(Tarefa tarefa){
String sql = “update tarefa set descricao = ?, data = ? where id = ?”;
try (PreparedStatement pstm = connection.prepareStatement(sql)){
pstm.setString(1, tarefa.getDescricao());
pstm.setDate(2, new Date(tarefa.getData().getTimeInMillis()));
pstm.setInt(3, tarefa.getId()); // Erro nessa linha, está dando Null
pstm.execute();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
view que recupera o objeto e atualiza.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Atualização de Tarefa</title>
<link href="css/estilo.css" rel="stylesheet">
</head>
<body>
<h3>Atualização de Tarefa - ${tarefa.id}</h3>
<form action="mvc?logica=AtualizaTarefaLogic&id=${tarefa.id}" method="post">
Data: <input type="text" name="data" value="<fmt:formatDate value="${tarefa.data.time}" pattern="dd/MM/yyyy" />" /> <br />
Descricao: <textarea rows="7" cols="20" name="descricao">${tarefa.descricao}</textarea> <br>
<input type="submit" value="Atualizar">
</form>
</body>
</html>