类型:例外报告
消息:An exception occurred processing JSP page /registration.jsp
说明:The server encountered an internal error that prevented it from fulfilling this request
。
异常:
org.apache.jasper.JasperException:在第14行处理JSP页面/registration.jsp时发生异常
Statement st = con.createStatement();
ResultSet rs;
int i = st.executeUpdate("insert into members(fname,lname,email,uname,pass) values (?,?,?,?,?)");
if (i > 0) {
session.setAttribute("userid", user);
response.sendRedirect("welcome.jsp");
堆栈跟踪:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:462)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因:
javax.servlet.ServletException: java.sql.SQLSyntaxErrorException: Invalid amount of bind variables
'insert into members(fname,lname,email,uname,pass) values (?,?,?,?,?)'
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
org.apache.jsp.registration_jsp._jspService(registration_jsp.java:116)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因
java.sql.SQLSyntaxErrorException: Invalid amount of bind variables
'insert into members(fname,lname,email,uname,pass) values (?,?,?,?,?)'
org.bigsql.cassandra2.jdbc.CassandraStatement.doExecute(CassandraStatement.java:188)
org.bigsql.cassandra2.jdbc.CassandraStatement.executeUpdate(CassandraStatement.java:252)
org.apache.jsp.registration_jsp._jspService(registration_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
根本原因
InvalidRequestException(why:Invalid amount of bind variables)
org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result$execute_cql3_query_resultStandardScheme.read(Cassandra.java:50297)
org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result$execute_cql3_query_resultStandardScheme.read(Cassandra.java:50274)
org.apache.cassandra.thrift.Cassandra$execute_cql3_query_result.read(Cassandra.java:50189)
org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:78)
org.apache.cassandra.thrift.Cassandra$Client.recv_execute_cql3_query(Cassandra.java:1734)
org.apache.cassandra.thrift.Cassandra$Client.execute_cql3_query(Cassandra.java:1719)
org.bigsql.cassandra2.jdbc.CassandraConnection.execute(CassandraConnection.java:548)
org.bigsql.cassandra2.jdbc.CassandraConnection.execute(CassandraConnection.java:574)
org.bigsql.cassandra2.jdbc.CassandraStatement.doExecute(CassandraStatement.java:171)
org.bigsql.cassandra2.jdbc.CassandraStatement.executeUpdate(CassandraStatement.java:252)
org.apache.jsp.registration_jsp._jspService(registration_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
答案 0 :(得分:0)
Statement st = con.createStatement();
您应该使用PreparedStatement
代替Statement
。例如:
PreparedStatement ps = conn.prepareStatement("insert into members(fname,lname,email,uname,pass) values (?,?,?,?,?)");
ps.setString(1,fname);
ps.setString(2,lname);
...