xml-xalan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moraine Didier" <didier.mora...@winterthur.be>
Subject Re: SQL Extension, how to close just one query?
Date Tue, 31 Aug 2004 15:37:51 GMT
Hem ...
You're right Phil, I have problem with my previous code also.

This one seems to work better ;-)

public void close(Object sqldoc) throws SQLException {
    if (DEBUG)
        System.out.println("Entering XConnection.close(" + sqldoc + ")");
        
    DTMNodeIterator dtmIter = (DTMNodeIterator)sqldoc;

    XNodeSet xNS = (XNodeSet)dtmIter.getDTMIterator();

    OneStepIterator iter = (OneStepIterator)xNS.getContainedIter();

    DTMManager aDTMManager = (DTMManager)iter.getDTMManager();

    SQLDocument sqlDoc = (SQLDocument)aDTMManager.getDTM(xNS.nextNode());

    sqlDoc.close();

}


-- 
Didier Moraine 
Winterthur-Europe Assurances 


-----Original Message-----
From: Phil Friedman [mailto:pfriedma@terralink.com]
Sent: vendredi 20 août 2004 22:31
To: xalan-dev@xml.apache.org
Subject: [SPAM] - Re: SQL Extension, how to close just one query? -
Email has different SMTP TO: and MIME TO: fields in the email addresses


Thanks, but this still does not work for me, maybe It is the nested queries.
I haven't the time to set up to debug this. I'm reverting to my hack which
always closes the most recently used connection with:

public void close( Object sqldoc )throws SQLException
{
  int size = m_OpenSQLDocuments.size();
  Object o = m_OpenSQLDocuments.elementAt(size-1);
  ((SQLDocument)o).close();
  m_OpenSQLDocuments.removeElementAt(size-1);
}

Yuk! :(

Regards, Phil Friedman - Terralink Software - 1-207-772-6500 x101

Moraine Didier wrote:

> [Trying to join the thread]
> 
> Hello, 
> 
> We have the same problem and this is what we tried today :
> 
> public void close( Object sqldoc ) throws SQLException {
>     if (DEBUG)
>         System.out.println("Entering XConnection.close(" + sqldoc + ")");
> 
>     if (sqldoc instanceof DTMNodeIterator) {
>            
>         DTMNodeIterator dtmIter = (DTMNodeIterator) sqldoc;
>             
>         if (dtmIter.getDTMIterator() instanceof XNodeSet) {
>                 
>             XNodeSet xNS = (XNodeSet) dtmIter.getDTMIterator();
> 
>             if (xNS.getContainedIter() instanceof OneStepIterator) {
>                     
>                 OneStepIterator iter = (OneStepIterator)
> xNS.getContainedIter();
>                 DTMManager dtmMgr = (DTMManager) iter.getDTMManager();
>                     
>                 //Finally :-)
>                 if (dtmMgr.getDTM(xNS.nextNode()) instanceof SQLDocument)
{
>                         
>                     sqldoc = (SQLDocument) dtmMgr.getDTM(xNS.nextNode());
> 
>                     int size = m_OpenSQLDocuments.size();
> 
>                     for (int x = 0; x < size; x++) {
>                         SQLDocument d = (SQLDocument)
> m_OpenSQLDocuments.elementAt(x);
>                         if (d == sqldoc) {
>                             d.close();
>                             m_OpenSQLDocuments.removeElementAt(x);
>                         }
>                     }
>                 } else {
>                     throw new RuntimeException(
>                             "Class cast exception
XConnection.close(Object)
> !");
>                 }
>             } else {
>                 throw new RuntimeException(
>                         "Class cast exception XConnection.close(Object)
!");
>             }
>         } else {
>             throw new RuntimeException(
>                     "Class cast exception XConnection.close(Object) !");
>         }
>     }
> }
> 
> We are now able to close a single SQLDocument and put back the connection
in
> the pool
> with :
> 
> <xsl:variable name="Qy" select="sql:query($DbCon, $SQL)"/>
> ...
> <xsl:value-of select="sql:close($DbCon, $Qy)"/>
> 
> Regards,
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org

________________________________________________________________________________
Disclaimer - Winterthur Europe Assurances - Avenue des Arts/Kunstlaan 56 -  1000 Brussels
- Belgium.
This e-mail is intended solely for the above-mentioned recipient and it may contain confidential
or privileged information. If you have
received it in error, please notify the sender immediately and delete the e-mail. You must
not copy, distribute, disclose or take any
action in reliance on it. 
This e-mail message and any attached files have been scanned for the presence of computer
viruses. However, you are advised that 
you open any attachments at your own risk. 



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


Mime
View raw message