return;
}
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
{
lastExecutedStatement = querySql;
if (!processQuery(querySql, processedStatementCount, statementCount))
{
break;
}
}
catch (SQLException ex)
{
// If the user has cancelled the query, don't bother logging
// an error message. It is likely that the cancel request
// interfered with the attempt to fetch results from the
// ResultSet, which is to be expected when the Statement is
// closed. So, let's not bug the user with obvious error
// messages that we can do nothing about.
if (_stopExecution) {
break;
} else {
if (props.getAbortOnError())
{
throw ex;
}
else
{
if(1 < statementCount)
{
handleError(ex, "Error occured in:\n" + lastExecutedStatement);
}
else
{
handleError(ex, null);
}
}
}
}
}
}
}
finally
{
try
{
_stmt.close();
}
finally
{
_stmt = null;
}
}
}
catch (Throwable ex)
{
if(props.getAbortOnError() && 1 < statementCount)
{
handleError(ex, "Error occured in:\n" + lastExecutedStatement);
}
else
{