web提交页面出错,来个大神来看看啊!!!!
Java code
<%@ page language="java" import="java.util.*,java.sql.*,bbs.*"
pageEncoding="GB18030"%>
<%
request.setCharacterEncoding("UTF-8");
int pid = Integer.parseInt(request.getParameter("pid"));
int rootId = Integer.parseInt(request.getParameter("rootId"));
String title = request.getParameter("title");
System.out.println(title);
String cont = request.getParameter("cont");
System.out.println(cont);
Connection conn = DB.getConn();
String sql = "insert into article values(?,?,?,?,sysdate,?)";
PreparedStatement pstmt = DB.prepareStmt(conn, sql);
pstmt.setInt(1, pid);
pstmt.setInt(2, rootId);
pstmt.setString(3, title);
pstmt.setString(4, cont);
pstmt.setInt(5, 0);
pstmt.executeUpdate();
DB.close(pstmt);
DB.close(conn);
%>
String sql = "insert into article values(?,?,?,?,sysdate,?)";
这样写提示出错:
org.apache.jasper.JasperException: An exception occurred processing JSP page /replyDeal.jsp at line 24
21: pstmt.setString(3, title);
22: pstmt.setString(4, cont);
23: pstmt.setInt(5, 0);
24: pstmt.executeUpdate();
25: DB.close(pstmt);
26: DB.close(conn);
27: %>
javax.servlet.ServletException:
java.sql.SQLException: ORA-00947: 没有足够的值
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.replyDeal_jsp._jspService(replyDeal_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
----------------------------------------
String sql = "insert into article values(null,?,?,?,?,sysdate,?)";
这样写提示出错:
javax.servlet.
ServletException: java.sql.
SQLException: ORA-01400: 无法将 NULL 插入 ("SCOTT"."ARTICLE"."ID")
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.replyDeal_jsp._jspService(replyDeal_jsp.java:122)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
----------------------------------------
数据库里ID号设置的是自增的
create sequence seq_article increment by 1 start with 1;
到底是哪里出错了,求解.....
------解决方案--------------------楼主 把sql语句换成这样子:
String sql = &q