{
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
DTMManagerDefault mgrDefault = null;
SQLDocument doc = null;
try
{
if (DEBUG) System.out.println("query()");
if (null == m_ConnectionPool)
{
// Build an Error Document, NOT Connected
return null;
}
try
{
con = m_ConnectionPool.getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery(queryString);
}
catch(SQLException e)
{
// We have not created a document yet, so lets close the
// connection ourselves then let the process deal with the
// error.
//
try { if (null != rs) rs.close(); }
catch(Exception e1) {}
try { if (null != stmt) stmt.close(); }
catch(Exception e1) { }
try {
if (null != con) m_ConnectionPool.releaseConnectionOnError(con);
} catch(Exception e1) { }
buildErrorDocument(exprContext, e);
return null;
}
if (DEBUG) System.out.println("..creatingSQLDocument");
DTMManager mgr =
((XPathContext.XPathExpressionContext)exprContext).getDTMManager();
mgrDefault = (DTMManagerDefault) mgr;
int dtmIdent = mgrDefault.getFirstFreeDTMID();
doc =
new SQLDocument(
mgr, dtmIdent << DTMManager.IDENT_DTM_NODE_BITS ,
m_ConnectionPool, con, stmt, rs, m_IsStreamingEnabled);
if (null != doc)
{
if (DEBUG) System.out.println("..returning Document");
// Register our document
mgrDefault.addDTM(doc, dtmIdent);
// also keep a local reference
m_OpenSQLDocuments.addElement(doc);
return doc;
}
else
{
return null;
}
}
catch(SQLException e)
{
if ((doc != null) && (mgrDefault != null))
{
doc.closeOnError();
mgrDefault.release(doc, true);
}
buildErrorDocument(exprContext, e);
return null;
}
catch (Exception e)
{
if ((doc != null) && (mgrDefault != null))
{
doc.closeOnError();
mgrDefault.release(doc, true);
}
if (DEBUG) System.out.println("exception in query()");
buildErrorDocument(exprContext, e);
return null;