type Status report
message Servlet Banco is currently unavailable
description The requested service (Servlet Banco is currently unavailable) is not currently available.
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Class br.com.ctis.Banco is not a Servlet
..
..
..
..
root cause
java.lang.ClassCastException
..
..
..
<form action="banco" method="POST" >
public class Banco
{
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
String nome = request.getParameter("nome");
String email = request.getParameter("email");
String user = request.getParameter("user");
String password = request.getParameter("password");
Conectar.inserir(nome, email, user, password);
response.sendRedirect("http://localhost:8080/Leo/cadastroOK.jsp");
}
}
public class Conectar
{
public static Connection getConnection()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
return DriverManager.getConnection("jdbc:odbc:Banco","1234","1234");
}
catch (ClassNotFoundException e)
{
System.out.println("Conectar-ClassNotFoundException");
}
catch (SQLException e1)
{
System.out.println("Conectar-SQLException");
}
return null;
}
static void inserir(String nome, String email, String user, String password)
{
try
{
Connection con = Conectar.getConnection();
Statement stat = con.createStatement();
stat.executeUpdate("INSERT INTO Teste(nome,mail, user, password) VALUES ('" + nome + "', '" + email + "','" + user + "', '" + password + "')");
stat.close();
con.close();
}
catch(Exception e)
{
System.out.println("Erro no comando de SQL INSERT: " + e.toString());
}
}
}
Então, depois de muito código, alguem saberia me dizer o que tem de erro nisto? :oops:
espero sua ajuda pessoal.
abraços