首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

PreparedStatement pstmt=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEY

2013-09-11 
PreparedStatement pstmtconn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS)oracle出现java.s

PreparedStatement pstmt=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);oracle出现java.sql.SQLException: 不支持的特性的错误,什么原因
 
  
HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

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

21: conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
22: conn.setAutoCommit(false);
23: String sql="insert into article values (auto.nextVal,0,-1,?,?,sysdate,0)";
24: PreparedStatement pstmt=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
25: pstmt.setString(1,title);
26: pstmt.setString(2,cont);
27: pstmt.executeUpdate();


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

javax.servlet.ServletException: java.sql.SQLException: 不支持的特性
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.Post_jsp._jspService(Post_jsp.java:144)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause 

java.sql.SQLException: 不支持的特性
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:226)
oracle.jdbc.driver.DatabaseError.throwUnsupportedFeatureSqlException(DatabaseError.java:536)
oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:2866)
org.apache.jsp.Post_jsp._jspService(Post_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.13 logs.


--------------------------------------------

Apache Tomcat/6.0.13
 

 

 

2008-4-21 15:18:30 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet jsp threw exception
java.sql.SQLException: 不支持的特性
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:124)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:161)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:226)
 at oracle.jdbc.driver.DatabaseError.throwUnsupportedFeatureSqlException(DatabaseError.java:536)
 at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:2866)


 at org.apache.jsp.Post_jsp._jspService(Post_jsp.java:81)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Unknown Source)


 
 

[解决办法]
insert 时把Statement.RETURN_GENERATED_KEYS去掉
[解决办法]
是不是连接字符串写错了,贴出来看下
[解决办法]
conn=DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
22: conn.setAutoCommit(false);
23: String sql="insert into article values (auto.nextVal,0,-1,?,?,sysdate,0)";
24: PreparedStatement pstmt=conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
25: pstmt.setString(1,title);
26: pstmt.setString(2,cont);
27: pstmt.executeUpdate();


楼主的意思好像是用到Statement.RETURN_GENERATED_KEYS 让主键自动增长吗,可以在数据库设置自动增长阿,这样这里就不用显示插入字段了
[解决办法]
看jdbc的doc就知道了,到底支不支持,有什么依赖
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行