If you are doing cached requests (the default) then
you don't need to close the Session or the ResultSequence
because they hold no transactional state.  A cached request
completely reads the server response and releases the
connection before returning to you.

   A streaming request, specified by using a RequestOptions
object to disable caching, holds an open network connection
in the ResultSequence until it is closed.  ResultSequences
belong to Sessions.  Closing a Session closes any streaming
ResultSequences that are still open.

   Cached ResultSequences are not remembered by their Session,
so closing the Session in that case does nothing.  It's OK
to return a cached ResultSequence.  You should not return
a streaming ResultSequence unless the caller is prepared
to read out the content in a timely manner and close the
object when it's finished.

   Sessions contain information about where to connect and
how to authenticate.  You can use one Session per thread
to issue multiple request sequentially.  Closing a Session
cleans up any resources it's holding.  Currently, only
streaming ResultSequences are tracked by a Session.

On Nov 20, 2008, at 11:10 AM, Paul M wrote:

Hi:

I created a wrapper for ad hoc queries.

Here is a code snippet:
    Session session = contentSource.newSession();
        Request request = session.newAdhocQuery(adhocQry);
        ResultSequence rs = session.submitRequest(request);

        return(rs.asString());
}

some more code:
        Session session = contentSource.newSession();
        Request request = session.newAdhocQuery(adhocQry);
        ResultSequence rs = session.submitRequest(request);

        return(rs);
    }

Notice that the session is not being closed.
Even if I close it as follows:

    Session session = contentSource.newSession();
        Request request = session.newAdhocQuery(adhocQry);
        ResultSequence rs = session.submitRequest(request);
  session.close();
        return(rs);
}


It still "works". Is the result sequence separate from the session. Once submitRequest is executed, the session is no longer needed?


_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

---
Ron Hitchens [EMAIL PROTECTED]  650-655-2351




_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to