tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ULS Tech Support <tech_supp...@uls.com>
Subject Tomcat 5.59 with jTDS, and SQL Server 2005
Date Tue, 20 Oct 2009 18:18:37 GMT
Hi there,

Let's try this again...

I am using Tomcat 5.5.9, using jTDS, with SQL Server 2005 i am getting this issue.

2009/10/16 10:47:15 - sql exception:java.sql.SQLException: No current row in the ResultSet.

This issue doesn't happen with TWFreeTDS (in fact, when i switch to 
twfreetds it works fine).. but from my research so far, i may have been 
wrong in the way i implemented it.

Here is the code.

    public Vector queryPaged4(String strTableExt) throws SQLException {
        dbRecords.removeAllElements();
        boolean rc = true;

        ResultSet rs_info = null;
        boolean bTest = false;
        DBItems temp = null;

        //New **********
        /* This will call a stored procedure, pass in the page # and
        number to display on each page and will return the results
        directly.
         */

        CallableStatement call = dbConn.prepareCall("{call sp_PagedItems4 (?,?,?,?,?)}");
        call.setString(1, strTableExt);
        call.setString(2, filter);
        call.setString(3, order);
        call.setInt(4, pageNumber);
        call.setInt(5, recsPerPage);

        if (!call.execute())//Query
        {
            //No ResultSets Returned;
        } else {

            try {
                rs_info = call.getResultSet();

                //Save the total number of records (value) in 
queryPagedRecords
                queryPagedRecords = rs_info.getInt("TotalRec");
                queryPagedMore = rs_info.getInt("MoreRecords");
                nLowestID = rs_info.getInt("FirstRec");
                nHighestID = rs_info.getInt("LastRec");

                if (queryPagedRecords > 0) {
                    //Test for another resultset.
                    boolean bTest = false;
                    bTest = call.getMoreResults();
                    //Next resultset established, let's get the data!
                    dbResultSet = call.getResultSet();

                    while (dbResultSet.next()) {
                        //System.out.println("2: " + dbResultSet.getInt("ID"));
                        rc = true;

                        //Set the items object based on the resultset.
                        temp = this.setItemsObject(true, dbResultSet);

                        dbRecords.addElement(temp);
                    }
                }
            } catch (SQLException e) {
                System.out.println("SQLException: " + e);
                System.out.println("SQLException Message: " + e.getMessage());
            } finally {
                rs_info = null;
                temp = null;
                dbResultSet = null;
            }
            System.out.println("end");
        }

        return dbRecords;
    }

Basically i'm getting the resultsets, but i'm not able to pull the data from 
the resultsets as i get the error when i try and getInt.

Does anyone have any clue on why this is happening, or how i can make this 
work?

I did try and modify the code to the following to see if it helped, but 
again, i'm still stumped on HOW to retrieve the data from the resultsets.

            try {
                System.out.println("start...");
                int updateCount = 0;
                updateCount = call.getUpdateCount();
                System.out.println("update count = " + updateCount);
                boolean moreResults = true;
                while (updateCount >= 0 || moreResults) {
                    if (!moreResults) {
                        // just eat it
                        updateCount = call.getUpdateCount();
                        System.out.println("\nupdateCount= " + updateCount);
                    } else {
                        // get the data
                        if (rs_info == null) {
                            rs_info = call.getResultSet();
                        } else {
                            dbResultSet = call.getResultSet();
                        }

                        //Save the total number of records (value) in queryPagedRecords
                        System.out.println("Got Data, how to process??");
                    } // if ! moreResults else
                    moreResults = call.getMoreResults();
                    System.out.println("More Results??");
                } // while

                //rs_info.setFetchSize();
                System.out.println("Lets get data from rs_info");
                queryPagedRecords = rs_info.getInt("TotalRec");
                queryPagedMore = rs_info.getInt("MoreRecords");
                nLowestID = rs_info.getInt("FirstRec");
                nHighestID = rs_info.getInt("LastRec");

But it stops at the "queryPagedRecords = rs_info.getInt("TotalRec");"

Thanks in advance to anyone who can help.

...Robin

 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message