即使在向类路径添加mysql连接器之后,也会将异常消息显示为“com.mysql.jdbc.Driver”

时间:2013-05-05 19:05:27

标签: mysql jsp

我的代码如下:

<body>
<%@ page import = "java.sql.*"  %>

<%!
    String fn,ln,dob,gender,exp,aoe,address,cno,comments,uname,pass;
    int sno=1;
%>

<%
    fn=request.getParameter("fn");
    ln=request.getParameter("ln");
    dob=request.getParameter("dob");
    gender=request.getParameter("gender");
    exp=request.getParameter("exp");
    aoe=request.getParameter("aoe");
    address=request.getParameter("address");
    cno=request.getParameter("cno");
    comments=request.getParameter("comments");
    uname=request.getParameter("uname");
    pass=request.getParameter("pass");

    //out.println("First Name: "+fn+" Last Name: "+ln+" Date:"+dob+" Gender:"+gender+"         Experience:"+exp+" Proficiency:"+aoe+" 

//Address:"+address+" Contact No:"+cno+" Comments:"+comments+" Username:"+uname+"     Password:"+pass);

    try
    {
        Connection con=null;
        PreparedStatement ps=null;
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        out.println("Connect to db!");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/work2workers","root","root");
ps = con.prepareStatement("insert into newuser values('"+sno+"','"+fn+"','"+ln+"','"+dob+"','"+gender+"','"+exp+"','"+aoe+"','"+address+"','"+cno+"','"+comments+"','"+uname+"','"+pass+"')");
        ps.executeUpdate();
        con.close();
        ps.close();
        //response.sendRedirect("Login.jsp");

    }
    catch (Exception e)
    {
        out.println(""+e.getMessage());
    }

%>
</body>

作为一名程序员我很好,但是这个异常似乎很难消除。我甚至尝试将mysql-connector-java-5.0.8-bin.jar添加到类路径中。

0 个答案:

没有答案