db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rico Setiawan (JIRA)" <j...@apache.org>
Subject [jira] Created: (DDLUTILS-170) org.apache.ddlutils.platform.PlatformImplBase Problem! Urgent!
Date Fri, 20 Apr 2007 04:29:15 GMT
org.apache.ddlutils.platform.PlatformImplBase Problem! Urgent!

                 Key: DDLUTILS-170
                 URL: https://issues.apache.org/jira/browse/DDLUTILS-170
             Project: DdlUtils
          Issue Type: Bug
          Components: Core (No specific database)
            Reporter: Rico Setiawan
         Assigned To: Thomas Dudziak

Hi I found a bug at org.apache.ddlutils.platform.PlatformImplBase, when you want to fecth
database per-n data then you will use fecth(...,start,end). But it seems the method doesn't
work properly.

org.apache.ddlutils.platform.PlatformImplBase at line 990 :

    public List fetch(Database model, String sql, Table[] queryHints, int start, int end)
throws DatabaseOperationException
        Connection connection = borrowConnection();
        Statement  statement  = null;
        ResultSet  resultSet  = null;
        List       result     = new ArrayList();

            statement = connection.createStatement();
            resultSet = statement.executeQuery(sql);

            int rowIdx = 0;

            for (Iterator it = createResultSetIterator(model, resultSet, queryHints); ((end
< 0) || (rowIdx <= end)) && it.hasNext(); rowIdx++)
                if (rowIdx >= start)
        catch (SQLException ex)
            throw new DatabaseOperationException("Error while fetching data from the database",
            // the iterator should return the connection automatically
            // so this is usually not necessary (but just in case)
        return result;

Take a look line 1008, the pointer (Iterator it) never come forward if rowIdx >=start..Indeed
at the real case its really possible the start point is not came from 0..

For example start=10 and end=100

In current code, the pointer will always start from 0 since nobody move that pointer..

My fixed code : 

                if (rowIdx >= start)

In My fixed code, the pointer will start from 10 since I added it.next();
Rico Setiawan

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message