HttpServletResponse response)
throws IOException, ServletException {
synchronized (this) {
DataInputStream inStream = null;
DataOutputStream dataOut = null;
try {
// fredt@users - the servlet container, Resin does not return all
// the bytes with one call to input.read(b,0,len) when len > 8192
// bytes, the loop in the Result.read() method handles this
inStream = new DataInputStream(request.getInputStream());
int databaseID = inStream.readInt();
long sessionID = inStream.readLong();
int mode = inStream.readByte();
Session session = DatabaseManager.getSession(databaseID,
sessionID);
Result resultIn = Result.newResult(session, mode, inStream,
rowIn);
resultIn.setDatabaseId(databaseID);
resultIn.setSessionId(sessionID);
Result resultOut;
if (resultIn.getType() == ResultConstants.CONNECT) {
try {
session = DatabaseManager.newSession(
dbType, dbPath, resultIn.getMainString(),
resultIn.getSubString(), new HsqlProperties(),
resultIn.getZoneString(),
resultIn.getUpdateCount());
resultIn.readAdditionalResults(null, inStream, rowIn);
resultOut = Result.newConnectionAcknowledgeResponse(
session.getDatabase(), session.getId(),
session.getDatabase().getDatabaseID());
} catch (HsqlException e) {
resultOut = Result.newErrorResult(e);
}
} else {
int dbId = resultIn.getDatabaseId();
long sessionId = resultIn.getSessionId();
session = DatabaseManager.getSession(dbId, sessionId);
resultIn.readLobResults(session, inStream, rowIn);
resultOut = session.execute(resultIn);
}
//
response.setContentType("application/octet-stream");
response.setContentLength(rowOut.size());
//
dataOut = new DataOutputStream(response.getOutputStream());
resultOut.write(session, dataOut, rowOut);
iQueries++;
} catch (HsqlException e) {}
finally {
if (dataOut != null) {
dataOut.close();
}
if (inStream != null) {
inStream.close();
}