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();
try
{
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)
{
result.add(it.next());
}
}
}
catch (SQLException ex)
{
throw new DatabaseOperationException("Error while fetching data
from the database", ex);
}
finally
{
// the iterator should return the connection automatically
// so this is usually not necessary (but just in case)
closeStatement(statement);
returnConnection(connection);
}
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)
{
result.add(it.next());
}
else
it.next();
In My fixed code, the pointer will start from 10 since I added it.next();
Regards,
Rico Setiawan
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.