jsp更新查询不起作用

时间:2016-08-28 15:24:30

标签: jsp sql-update

这是我的jsp

<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page import="com.dbcon.util.Dbconnect"%>
<%
    String password = request.getParameter("newpass");
    String retypePass = request.getParameter("retypenewpass");
    String uname = request.getParameter("f_name");
    Connection con = Dbconnect.getMySqlConnection();
    Statement st = con.createStatement();
    int i = st.executeUpdate("UPDATE Customers SET PASSWORD='" + password + "' and RETYPE_PASSWORD='" + retypePass + " WHERE USERNAME='" + uname +"'");              

    if (i > 0) {
        out.println("Password Changed <a href='login.jsp'>click here</a> to login");
    } else {
        out.println("Wrong passwords");
        response.sendRedirect("forgot.jsp");
    }
%>

错误是

exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /newpasschecker.jsp at line 10

7:  String uname = request.getParameter("f_name");
8:     Connection con = Dbconnect.getMySqlConnection();
9:  Statement st = con.createStatement();
10:     int i = st.executeUpdate("UPDATE Customers SET PASSWORD='" + password + "' and RETYPE_PASSWORD='" + retypePass + " WHERE USERNAME='" + uname +"'");              
11:  
12:     if (i > 0) {
13:         out.println("Password Changed <a href='login.jsp'>click here</a> to login");


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

任何帮助将不胜感激....

0 个答案:

没有答案