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 {
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);
int columnCount = transfer.readInt();
if (result != null) {
result.close();
result = null;
}
result = new ResultRemote(session, transfer, objectId, columnCount, fetch);
if (readonly) {
break;
}
} catch (IOException e) {
session.removeServer(e, i--, ++count);