sql = reader.readStatement();
modfiedSQL = fixSQL(sql);
}
while (modfiedSQL != null) {
try {
final StatementImpl stmt = connection.createStatement();
executionFuture = stmt.submitExecute(modfiedSQL);
executionFuture.addCompletionListener(new ResultsFuture.CompletionListener<Boolean>() {
@Override
public void onCompletion(ResultsFuture<Boolean> future) {
executionFuture = null;
try {
ResultsFuture<Void> result = null;
if (future.get()) {
if (stmt.getResultSet() != null) {
result = new ResultsFuture<Void>();
client.sendResults(sql, stmt.getResultSet(), result, true);
}
else {
// handles the "SET" commands.
result = ResultsFuture.NULL_FUTURE;
client.sendUpdateCount(sql, 0);
}
} else {
result = ResultsFuture.NULL_FUTURE;
client.sendUpdateCount(sql, stmt.getUpdateCount());
setEncoding();
}
result.addCompletionListener(new ResultsFuture.CompletionListener<Void>() {
public void onCompletion(ResultsFuture<Void> future) {
try {
future.get();
sql = reader.readStatement();
modfiedSQL = fixSQL(sql);
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (IOException e) {
client.errorOccurred(e);
return;
} catch (ExecutionException e) {
client.errorOccurred(e.getCause());
return;
} finally {
try {
stmt.close();
} catch (SQLException e) {
LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing statement"); //$NON-NLS-1$
}
}
QueryWorkItem.this.run(); //continue processing