Ajouter un commentaire

markove
base de donne dans une servlet

Bonjour je ne sais pas pk je n'arrive pas afficher ce code


import java.sql.*;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class reyperation
 */
public class reyperation extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public reyperation() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		PrintWriter out=response.getWriter();
		out.println("ok");
		String user = "root";
	    String pass = "root";
try{
	    Class.forName("com.mysql.jdbc.Driver").newInstance();
	    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mourad", user, pass);
	    Statement st = con.createStatement();
	    ResultSet res =st.executeQuery("select * from personne");
	    while(res.next()){
	    out.println(res.getString(2));}
	    con.close();
	}catch(Exception e)
	{
		
	}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}}

merci j'ai utilise mysql

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 N   N  PPPP   W     W   GGG   BBBB  
NN N P P W W G B B
N N N PPPP W W W G GG BBBB
N NN P W W W G G B B
N N P W W GGG BBBB