Ajouter un commentaire

markove
jdbc dans un servlet

Bonjour je n'arrive a exécuter ce programme même j'ai ajouter le jar mysql est ce qu'il y a quelqu'un qui pourra résoudre mon problème

import java.sql.*;
import java.io.IOException;
import java.io.PrintWriter;

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

/**
 * Servlet implementation class tt
 */
public class tt extends HttpServlet {
	private static final long serialVersionUID = 1L;

    /**
     * Default constructor. 
     */
    public tt() {
    	
        // 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("gu");

		
		try{
			Class.forName("com.mysql.jdbc.Driver");
			out.println("hu");
			Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
			Statement st=con.createStatement();
			int t=st.executeUpdate("Delete from client where id='64'");
				
				out.println(t);
		}catch(Exception e){
			out.println(e.getMessage());}
		}
	
	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub

	
		}
}

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 K  K  X   X      J  RRRR       J 
K K X X J R R J
KK X J RRRR J
K K X X J J R R J J
K K X X JJJ R RR JJJ