[Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 7.

From: Bill Fan (bil..anscom.com.au)
Date: Tue Dec 16 2003 - 05:42:47 EST

  • Next message: Andrus Adamchik: "Re: [Microsoft][SQLServer 2000 Driver for JDBC]ResultSet can not re-read row data for column 7."

    Hi,
     
    This problem sometimes (not always...) happened in my web application. I
    understand this is something to do with MS SQL database. I'm not sure how I
    can fix it when I'm using Cayenne.
     
    The way to fix it In the straight JDBC way, I would specify the table
    columns in a particular order in the sql query so that the columns with
    primitive data type(int, float, char etc) appears first, then the varchar
    columns, then the text columns appear last. When the resultset is being
    looping through, I would retrieve the values following straightly the order
    of columns in the query. With Cayenne, I'm running out of idea....
     
    Please note, the line has problem in the function below as indicated by the
    Stack trace is
     
            List issueRows = ctxt.performQuery(query);
     
     
    Here is the function caused the problem:
     
    ==================================
        /**
         * This funcion retrieves a list of the particular type of issue objects
    with status not CLOSED
         *..aram ctxt The DataContext to get the issue object from
         *..aram projectname The project name
         *..aram issueTypeDesc The issue type description
         *..eturn The issue objects list
         */
        private List getIssuesByType(DataContext ctxt, String projectname,
    String issueTypeDesc)
        {
     
    //**************************************************************************
    ***********************
            // The following commented out block of statements caused sql
    exception
            // "java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
    JDBC]ResultSet can not re-read row data for column 3."
            // So, have to use Using Raw SQL query instead!!
     
    //**************************************************************************
    ***********************
            //Expression qualifier =
    ExpressionFactory.binaryPathExp(Expression.EQUAL_TO,
            //
    "projectArray.projectname",
            //
    projectname);
            //qualifier = qualifier.andExp(
    ExpressionFactory.binaryPathExp(Expression.EQUAL_TO,
            //
    "issuetypeArray.issuetypedesc",
            //
    issueTypeDesc) );
            //qualifier = qualifier.andExp(
    ExpressionFactory.binaryPathExp(Expression.NOT_EQUAL_TO,
            //
    "issuestatusArray.issuestatusdesc",
            // "CLOSED")
    );
            //
            //SelectQuery query = new SelectQuery("Issue", qualifier);
            //
            //Ordering ordering = new Ordering("datesubmitted", Ordering.DESC);
            //
            //query.addOrdering(ordering);
            //
            //// set a relatively high logging level, to show the query
    execution progress
            //query.setLoggingLevel(Level.WARN);
            //
            //List issues = ctxt.performQuery(query);
            //
            
            List issues = new ArrayList();
            
            String sql = "SELECT ISSUE.IssueId, ISSUE.ProjectId,
    ISSUE.BranchId, ISSUE.IssueName, ISSUE.Model, ISSUE.PrdHa,
    ISSUE.IssueSymptoms, ISSUE.IssueDescription, "
                            + " ISSUE.IssueEnvironment,
    ISSUE.ActionsTaken, ISSUE.BranchRefNum, ISSUE.ModelAndSerialNum,
    ISSUE.AssociatedModelAndSerialNum, "
                            + " ISSUE.RaisedByUserId,
    ISSUE.PriorityId, ISSUE.IssueTypeId, ISSUE.IssueStatusId,
    ISSUE.CurrentActionOnUserId, ISSUE.CurrentAssignedToUserId, "
                            + " ISSUE.InitAssignedToUserId,
    ISSUE.DateSubmitted, ISSUE.DateModified, ISSUE.RequestTypeId, ISSUE.PartNo,
    ISSUE.OrderNo, ISSUE.ASCName, "
                            + " ISSUE.ASCContactPerson,
    ISSUE.InitialAdditionalInfo, ISSUE.CustomerTitle, ISSUE.CustomerFirstname,
    ISSUE.CustomerSurname, "
                            + " ISSUE.CustomerAddress,
    ISSUE.CustomerHomePhone, ISSUE.CustomerWorkPhone, ISSUE.CustomerMobile,
    ISSUE.CustomerEmail, "
                            + " ISSUE.DateOfIncident,
    ISSUE.PlaceOfIncident, ISSUE.DateOfPurchase, ISSUE.IsGotParts,
    ISSUE.DamageDescription, ISSUE.DamagePartsDescription, "
                            + " ISSUE.IsReportedToPolice,
    ISSUE.ReportToPoliceDetail, ISSUE.IsCompleted, ISSUE.DateCompleted "
                            + "FROM ISSUE INNER JOIN "
                            + " ISSUETYPE ON
    ISSUE.IssueTypeId = ISSUETYPE.IssueTypeId INNER JOIN "
                            + " PROJECT ON ISSUE.ProjectId
    = PROJECT.ProjectId INNER JOIN "
                            + " ISSUESTATUS ON
    ISSUE.IssueStatusId = ISSUESTATUS.IssueStatusId "
                            + "WHERE (PROJECT.ProjectName = '" +
    projectname.replaceAll("'", "''") + "') AND (ISSUETYPE.IssueTypeDesc = '" +
    issueTypeDesc.replaceAll("'", "''") + "') AND "
                            + "
    (ISSUESTATUS.IssueStatusDesc <> 'CLOSED') "
                            + "ORDER BY ISSUE.DateSubmitted DESC";
     
            SqlSelectQuery query = new SqlSelectQuery(Issue.class, sql);
            //Issue.class is used to find the right DataNode for query
    execution, not for object creation.
            //So this can be any class from the DataMap that maps to a correct
    DataNode.
            
            List issueRows = ctxt.performQuery(query);

            Iterator it = issueRows.iterator();
            
            while ( it.hasNext() )
            {
                // since query was configured to return data rows, result list
    elements are java.util.Map's
                Map row = (Map)it.next();
     
                // convert row to an issue
                Issue issue = (Issue)ctxt.objectFromDataRow("Issue", row);
                
                // add it to the list
                issues.add(issue);
            }
     
            return issues;
        }
    ==================================
     
     
     
    The following is the Exception Stack trace:
     
    2003-12-16 15:29:48 1071548988156 : Exception :class
    org.objectstyle.cayenne.CayenneRuntimeException
    2003-12-16 15:29:48 1071548988156: Stack :
    org.objectstyle.cayenne.CayenneRuntimeException: Global exception.
     at
    org.objectstyle.cayenne.access.util.SelectObserver.nextGlobalException(Selec
    tObserver.java:156)
     at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:331)
     at
    org.objectstyle.cayenne.access.DataDomain.performQueries(DataDomain.java:427
    )
     at
    org.objectstyle.cayenne.access.DataContext.performQueries(DataContext.java:7
    57)
     at
    org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:846
    )
     at
    org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:694
    )
     at
    com.issuemanager.action.ListProjectIssuesAction.getIssuesByType(ListProjectI
    ssuesAction.java:188)
     at
    com.issuemanager.action.ListProjectIssuesAction.execute(ListProjectIssuesAct
    ion.java:105)
     at
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProces
    sor.java:446)
     at
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:266)
     at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1292)
     at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
     at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
     at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:256)
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
     at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:191)
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
     at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
    .java:553)
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
     at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
     at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    )
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
     at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:171)
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
     at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
    )
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:641)
     at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
     at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643)
     at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
     at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
     at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:193)
     at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:309)
     at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:387)
     at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
     at
    org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
     at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
     at
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
    a:666)
     at java.lang.Thread.run(Thread.java:534)
    Caused by: org.objectstyle.cayenne.CayenneRuntimeException: Query exception.
     at
    org.objectstyle.cayenne.access.util.SelectObserver.nextQueryException(Select
    Observer.java:147)
     at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:288)
     ... 45 more
    Caused by: org.objectstyle.cayenne.CayenneException: Exception materializing
    column.
     at
    org.objectstyle.cayenne.access.DefaultResultIterator.readDataRow(DefaultResu
    ltIterator.java:239)
     at
    org.objectstyle.cayenne.access.DefaultResultIterator.nextDataRow(DefaultResu
    ltIterator.java:186)
     at
    org.objectstyle.cayenne.access.DefaultResultIterator.dataRows(DefaultResultI
    terator.java:206)
     at org.objectstyle.cayenne.access.DataNode.runSelect(DataNode.java:365)
     at
    org.objectstyle.cayenne.access.DataNode.performQueries(DataNode.java:278)
     ... 45 more
    Caused by: java.lang.reflect.InvocationTargetException
     at sun.reflect.GeneratedMethodAccessor154.invoke(Unknown Source)
     at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
    .java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at
    org.objectstyle.cayenne.access.types.DefaultType.materializeObject(DefaultTy
    pe.java:139)
     at
    org.objectstyle.cayenne.access.DefaultResultIterator.readDataRow(DefaultResu
    ltIterator.java:225)
     ... 49 more
    Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
    JDBC]ResultSet can not re-read row data for column 7.
     at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
     at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
     at com.microsoft.jdbc.base.BaseResultSet.validateColumnIndex(Unknown
    Source)
     at com.microsoft.jdbc.base.BaseResultSet.getInt(Unknown Source)
     ... 54 more
     
     
     
    Thanks very much for your help!
     
    Bill
     
     
     



    This archive was generated by hypermail 2.0.0 : Tue Dec 16 2003 - 05:42:52 EST