3 Replies Latest reply: Apr 5, 2007 7:39 AM by 807606 RSS

    java.sql.SQLException

    807606
      Hi all,

      I'm trying to iterate through a resultset then i'm getting the following error.

      java.sql.SQLException: sp_cursorfetch: The value of parameter 'nrows' is invalid.
           at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:364)
           at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2708)
           at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2150)
           at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:587)
           at net.sourceforge.jtds.jdbc.MSCursorResultSet.cursorFetch(MSCursorResultSet.java:751)
           at net.sourceforge.jtds.jdbc.MSCursorResultSet.next(MSCursorResultSet.java:1139)
           at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:168)
           at com.delphisoft.common.DBUtils.convertToXml(DBUtils.java:621)


      Here is a snippet of my code

           
           Statement stmt = null;
                ResultSet rs = null;
      
                stmt = con.createStatement(
                     ResultSet.TYPE_SCROLL_INSENSITIVE,
                     ResultSet.CONCUR_READ_ONLY);
                DataSourceUtils.applyTransactionTimeout(stmt,
                     getDataSource());
                stmt.setFetchSize(pageSize);
                rs = stmt.executeQuery(sql);
      
                      while (rs.next() && rowCount++ < maxRows) {
                         //My Code
                      }
      Here on executing the rs.next the error is coming.

      Can any one help me
        • 1. Re: java.sql.SQLException
          807606
          Your code seems to be alright. I don�t get one thing....
          What�s the purpose of the variable rowCount???
          • 2. Re: java.sql.SQLException
            807606
            Hi.
            You�re using setFetchSize() to return a page containing only the first "pagesize" lines in your resultSet Ok?

            You only have to use next() to step through these "pagesize" lines.

            I don�t know if you�ll be able to step through on the next page(I think stmt doesn�t even bring another page but only the lines you specified in "pagesize")

            bye
            • 3. Re: java.sql.SQLException
              807606
              Hi.
              You�re using setFetchSize() to return a page
              containing only the first "pagesize" lines in your
              resultSet Ok?

              You only have to use next() to step through these
              "pagesize" lines.

              I don�t know if you�ll be able to step through on the
              next page(I think stmt doesn�t even bring another
              page but only the lines you specified in "pagesize")

              bye
              Hi,
              Thank you. The problem was, value of pageSize was Zero.