2016-08-02 117 views
0

類型:異常報告發生異常處理JSP頁面/registration.jsp

消息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:發生異常處理JSP頁/registration.jsp在管線14

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

感謝它解決了這個錯誤,但是數據沒有插入在cqlsh中創建的表中。 –

+0

你能夠從cqlsh插入數​​據嗎? –

回答

0

聲明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); 
    ... 
相關問題