web提交页面出错,来个大神来看看啊!!!!Java code%@ page languagejava importjava.util.*,java.sql.
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 = "insert into article values(seq_article.nextval,?,?,?,?,sysdate,?)";
[解决办法] 你在插一条试试 ,看是不是接着增长的,
有数据插入过的,自增会自己从下一个开始
另外建议不使用自增长来做主键
[解决办法] 探讨 引用: 楼主 把sql语句换成这样子: String sql = "insert into article values(seq_article.nextval,?,?,?,?,sysdate,?)"; 插是插上了,可是ID号不是接着的11,怎么是12嘞,换成seq_article.currval会报错
[解决办法] 定楼上的!
抱的错误是500预编译错误,如果你用的oracle数据库
插入语句:String sql = "insert into article values(seq_article.nextval,?,?,?,?,sysdate,?)";
[解决办法] 既然ID是自增的,就不需要插了,插几个字段就放几个字段!
我的异常网推荐解决方案: An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html