O codigo abaixo eu tento buscar o nome atraves de um determinado email.Mas náo esta retornando nenhum resultado.Alguem sabe onde esta o erro?
[code]package Controller;
import java.io.;
import java.net.;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.servlet.;
import javax.servlet.http.;
public class Resgate extends HttpServlet {
private String TESTE_OK;
private String erro;
PreparedStatement stmt=null;
private String n;
ResultSet rs = null;
private String teste;
Connection con = null;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try{
String email=request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/teste","root","root");
stmt = con.prepareStatement("select nome from teste2 where email=?");
stmt.setString(1,email);
rs = stmt.executeQuery();
String nome;
int flag=0;
if (rs.next())
{
nome=rs.getString("nome");
request.setAttribute("nome","nome");
RequestDispatcher requestDispatcher= request.getRequestDispatcher("/index.jsp");
requestDispatcher.forward(request, response);
flag=1;
}
if (flag==1)
{
request.setAttribute("error","Dado nao encontrado");
RequestDispatcher requestDispatcher= request.getRequestDispatcher("/index.jsp");
requestDispatcher.forward(request, response);
}
}
catch(Exception e)
{
erro = e.getMessage();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}[/code]
[color=“red”]*Editado: lembre-se de usar BBCode em suas mensagens no forum. Jair Elton[/color]