try {
int fetchRows = 0;
int maxRows = 0;
int rowCount = 0;
int attrIndex = 0;
DBDataSet resultData = null;
SqlStatement statement = null;
Array_Of_BusinessClass<BusinessClass> result = sqlQuery.getQuery().newArray();
// There is text returned for each table but if nothing needs to be done
// to this particular table it might be empty. We only want to execute
// non-null queries so we check that now.
//
if (sqlText.getActualSize() > 0) {
maxRows = sqlQuery.getMaxRows();
if (maxRows == 0) {
maxRows = 2147483647;
}
statement = (SqlStatement)this.getStatementCache().find(sqlText);
if (this.getTrace().getOn() && this.getTrace().test(0, 0, Trace.ES_SELECT, 1, this, "SQLselect")) {
if (statement != null) {
Logger.getLogger("task.part.logmgr").info("using cached statement: ");
}
if (this.getTrace().test(0, 0, Trace.ES_SELECT, 50, (Object)null, (String)null)) {
Logger.getLogger("task.part.logmgr").info(this.formatSqlText(sqlText, sqlQuery.getData().get(0)));
}
else {
Logger.getLogger("task.part.logmgr").info(this.formatSqlText(sqlText, (SqlData)null));
}
}
if (statement == null) {
statement = new SqlStatement();
if (sqlQuery.getForUpdate() && this.getDB().getDBVendorType() == Constants.DB_VT_RDB) {
sqlQuery.getColumnList();
ParameterHolder qq_aTypeHolder = new ParameterHolder();
ParameterHolder qq_aColMapHolder = new ParameterHolder();
PreparedStatement qq_tempStatement = this.getDB().getDynamicStatement(
sqlText.toString(), qq_aTypeHolder, qq_aColMapHolder, true);
statement.setInputData(new DBDataSet(qq_tempStatement, (ArrayList)qq_aColMapHolder.getObject()));
statement.setHandle(qq_tempStatement);
}
else {
ParameterHolder qq_aTypeHolder = new ParameterHolder();
ParameterHolder qq_aColMapHolder = new ParameterHolder();
PreparedStatement qq_tempStatement = this.getDB().getDynamicStatement(
sqlText.toString(), qq_aTypeHolder, qq_aColMapHolder);
statement.setInputData(new DBDataSet(qq_tempStatement, (ArrayList)qq_aColMapHolder.getObject()));
statement.setHandle(qq_tempStatement);
}
this.getStatementCache().enter(statement, sqlText);
}
//
// Set the input values (constraints in this case).
//
for (int i = 1; i <= sqlData.getValues().size(); i++) {
statement.getInputData().setValue(i, sqlData.getValues().get(i-1));
}
PreparedStatement qq_statement = statement.getHandle();
@SuppressWarnings("unused")
int qq_rowType;
if (qq_statement.execute()) {
resultData = new DBDataSet(qq_statement, qq_statement.getResultSet());
qq_rowType = GenericDBMS.Constants.DB_RS_ROW;
}
else {
resultData = null;
qq_rowType = GenericDBMS.Constants.DB_RS_NONE;
}
fetchRows = resultData.getMaxRows();
if (fetchRows < 2) {
//
// The first time we fetch 10 rows. If there is more we will up this to 30.
//
fetchRows = 10;
}
rowCount = 0;
// Loop through each row returned from the DB creating a
// BusinessClass for each one and filling it with the data in the row.
//
PreparedStatement qq_tempStatement = statement.getHandle();
qq_tempStatement.setFetchSize(fetchRows);
if (resultData == null)
resultData = new DBDataSet(qq_tempStatement, qq_tempStatement.getResultSet());
while ((rowCount < maxRows) && (resultData.getResultSet().next())) {
if (rowCount+1 > maxRows) {
break;
}