0

这个问题是由于我认为因为我正在使用 getClob(1) 而我的数据库是 mysql,所以 CachedRowSet 可能在用 mysql 实现时遇到问题...... :(。如果我使用 getClob,它会给出类型不匹配并且当我转换时它到 String 并使用它给出以下异常....

public CachedRowSet viewQuery(String query) throws SQLException, Exception {
    //query = query;
    //CachedRowSetImpl crs =
    CachedRowSet crs = new CachedRowSetImpl();

    try {
        if (connection.isClosed()) {
            setConnection();
        }
    System.out.println("Connection count 1 : " + connectionCount);

        statement = connection.createStatement();
        rs = statement.executeQuery(query);

        crs.populate(rs);
        crs = crs.createCopy();
        closeConnection();
        System.out.println("Connection count 2 : " + connectionCount);

    } catch (Exception e) {
        e.printStackTrace();
    }

    return crs;
}       

例外 :

SEVERE: Servlet.service() for servlet jsp threw exception
    java.sql.SQLException: Invalid cursor position
         at com.sun.rowset.CachedRowSetImpl.next(Unknown Source)
         at
    org.apache.jsp.eTender.Buyer.TenderBidCre_jsp._jspService(TenderBidCre_jsp.java:1460)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
         at
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
         at
    org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
         at
    org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
         at
    org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)
         at org.apache.jsp.EProc_jsp._jspService(EProc_jsp.java:532)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         at
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
         at
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
         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:233)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
         at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
         at
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
     at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
     at java.lang.Thread.run(Unknown Source)
4

1 回答 1

0

您需要查看错误跟踪中的两个语句。

第一的,

 org.apache.jsp.eTender.Buyer.TenderBidCre_jsp._jspService(TenderBidCre_jsp.java:1460)

第二,

org.apache.jsp.EProc_jsp._jspService(EProc_jsp.java:532)

如果您使用的是 Tomcat,那么您将在以下位置找到已编译的 JSP/tomcat/work/Catalina/localhost/yourApp/org/apache/jsp

或者在您使用的地方提供 JSP CachedRowSet。问题就在那里。

可能很有用。

于 2012-07-25T09:03:48.417 回答