Estou tentando fazer o exercício (10.31) da apostila FJ-21 da Caelum, a primeira parte é mais visual é simples(É o primeiro código), a segunda parte ele teria que adicionar o contato, mas ao invés disso ele da esse erro:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: NO)
br.com.caelum.servlet.AdicionaContatoServlet.service(AdicionaContatoServlet.java:34)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.sql.SQLException: Access denied for user ‘root’@‘localhost’ (using password: NO)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.
<html>
<body>
Digite seus dados e pressione o botao:
<form action="testa-adiciona" method="POST">
Nome: <input type="text" name="nome" /><br/>
E-mail: <input type="text" name="email" /><br/>
Endereco: <input type="text" name="endereco" /><br/>
<input type="submit" value="Enviar" />
</form>
</body>
</html>
public class AdicionaContatoServlet extends HttpServlet {
protected void service(HttpServletRequest resquest,
HttpServletResponse response) throws ServletException, IOException {
Contato contato = new Contato();
String nome = resquest.getParameter("nome");
String endereco = resquest.getParameter("endereco");
String email = resquest.getParameter("email");
contato.setNome(nome);
contato.setEndereco(endereco);
contato.setEmail(email);
try {
ContatoDAO dao = new ContatoDAO();
dao.adiciona(contato);
} catch (SQLException e) {
throw new ServletException(e);
}
PrintWriter writer = response.getWriter();
writer.println("<html>");
writer.println("Contato Adicionado!");
writer.println("</html>");
}
}