@Override
public ResultInterface executeQuery(int maxRows, boolean scrollable) {
checkParameters();
synchronized (session) {
int objectId = session.getNextId();
ResultRemote result = null;
for (int i = 0, count = 0; i < transferList.size(); i++) {
prepareIfRequired();
Transfer transfer = transferList.get(i);
try {
boolean isDistributedQuery = session.getTransaction() != null && !session.getTransaction().isAutoCommit();
if (isDistributedQuery) {
session.traceOperation("COMMAND_EXECUTE_DISTRIBUTED_QUERY", id);
transfer.writeInt(SessionRemote.COMMAND_EXECUTE_DISTRIBUTED_QUERY).writeInt(id).writeInt(objectId)
.writeInt(maxRows);
} else {
session.traceOperation("COMMAND_EXECUTE_QUERY", id);
transfer.writeInt(SessionRemote.COMMAND_EXECUTE_QUERY) //
.writeInt(id).writeInt(objectId).writeInt(maxRows);
}
int fetch;
if (session.isClustered() || scrollable) {
fetch = Integer.MAX_VALUE;
} else {
fetch = fetchSize;
}
transfer.writeInt(fetch);
sendParameters(transfer);
session.done(transfer);
if (isDistributedQuery)
session.getTransaction().addLocalTransactionNames(transfer.readString());
int columnCount = transfer.readInt();
int rowCount = transfer.readInt();
if (result != null) {
result.close();
result = null;
}
if (rowCount < 0)
result = new ResultRemoteCursor(session, transfer, objectId, columnCount, fetch);
else