0

我的代码如下:

<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 添加到类路径中。

4

0 回答 0