1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class consulter extends HttpServlet
{
private Connection con;
private PrintWriter out;
public void init(ServletConfig conf) throws ServletException
{
super.init(conf);
try
{
//connexion
}
catch(Exception e)
{
System.out.println("erreur "+e);
}
}
public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
res.setContentType("text/html");
try
{
out = res.getWriter();
String pseudo ="";
pseudo =req.getParameter("nom");
System.out.println("code "+pseudo);
Statement instruction = con.createStatement();
String sql = " select code FROM test ";
ResultSet resultat1 = instruction.executeQuery(sql);
String valeur1;
while (resultat1.next()) {
valeur1= resultat1.getString("code");
if((valeur1.equals(pseudo))){
System.out.println("valeur est trouvé");
}
}
}
catch(SQLException e)
{
out.println("Exception SQL"+ e);
}
catch(IOException e)
{
}
}
public void destroy()
{
try
{
con.close();
}
catch(SQLException e)
{
;
}
}
} |
Partager