String lastExecutedStatement = null;
int statementCount = 0;
final SessionProperties props = _session.getProperties();
try
{
final ISQLConnection conn = _session.getSQLConnection();
_stmt = conn.createStatement();
try
{
if(props.getSQLUseFetchSize() && props.getSQLFetchSize() > 0)
{
setFetchSize(props);
}
final boolean correctlySupportsMaxRows = conn.getSQLMetaData()
.correctlySupportsSetMaxRows();
if (correctlySupportsMaxRows && props.getSQLLimitRows())
{
setMaxRows(props);
}
if(_tokenizer.getQueryCount() == 0)
{
throw new IllegalArgumentException("No SQL selected for execution.");
}
_currentQueryIndex = 0;
// Process each individual query.
boolean maxRowsHasBeenSet = correctlySupportsMaxRows;
int processedStatementCount = 0;
statementCount = _tokenizer.getQueryCount();
_handler.sqlStatementCount(statementCount);
while (_tokenizer.hasQuery() && !_stopExecution)
{
String querySql = _tokenizer.nextQuery();
if (querySql != null)
{
++processedStatementCount;
if (_handler != null)
{
_handler.sqlToBeExecuted(querySql);
}
// Some driver don't correctly support setMaxRows. In
// these cases use setMaxRows only if this is a
// SELECT.
if (!correctlySupportsMaxRows
&& props.getSQLLimitRows())
{
if (isSelectStatement(querySql))
{
if (!maxRowsHasBeenSet)
{
setMaxRows(props);
maxRowsHasBeenSet = true;
}
}
else if (maxRowsHasBeenSet)
{
_stmt.close();
_stmt = conn.createStatement();
maxRowsHasBeenSet = false;
}
}
try
{