johng       01/07/31 19:38:31

  Modified:    java/src/org/apache/xalan/lib/sql ConnectionPool.java
                        ConnectionPoolManager.java DTMDocument.java
                        DefaultConnectionPool.java ObjectArray.java
                        PooledConnection.java SQLDocument.java
                        SQLErrorDocument.java XConnection.java
  Log:
  Added Error Managment and javadocs
  Submitted by: John Gentilin
  
  Revision  Changes    Path
  1.8       +23 -44    
xml-xalan/java/src/org/apache/xalan/lib/sql/ConnectionPool.java
  
  Index: ConnectionPool.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/ConnectionPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionPool.java       2001/07/12 05:01:43     1.7
  +++ ConnectionPool.java       2001/08/01 02:38:30     1.8
  @@ -70,22 +70,12 @@
    * @author John Gentilin
    * @version 1.0
    */
  -public interface ConnectionPool         
  +public interface ConnectionPool
   {
  -  ///**
  -//   * The Pool can be Enabled and Disabled. Disabling the pool
  -//   * closes all the outstanding Unused connections and any new
  -//   * connections will be closed upon release.
  -//   * @return
  -//   */
  -//  public void enablePool( );
  -  
  -  ///**
  -//   * @return
  -//   */
  -//  public void disablePool( );
  -  
  +
     /**
  +   * Determine if a Connection Pool has been disabled. If a Connection pool
  +   * is disabled, then it will only manage connections that are in use.
      * @return
      */
     public boolean isEnabled( );
  @@ -96,6 +86,7 @@
      * @return
      */
     public void setDriver( String d );
  +
     /**
      * @param url
      * @return
  @@ -130,18 +121,14 @@
      * @return
      */
     public void setPassword( String p );
  +
     /**
      * @param u
      * @return
      */
     public void setUser( String u );
  -  ///**
  -//   * @param p
  -//   * @return
  -//   */
  -//  public void setProtocol( Properties p );
  +
   
  -  
     /**
      * Set tne minimum number of connections that are to be maintained in the
      * pool.
  @@ -162,18 +149,8 @@
      * Retrive a database connection from the pool
      * @return
      * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
      */
  -  public Connection getConnection( )throws SQLException         ;
  +  public Connection getConnection( )throws SQLException;
   
      /**
      * Return a connection to the pool, the connection may be closed if the
  @@ -181,30 +158,32 @@
      * @param con
      * @return
      * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  +   */
  +  public void releaseConnection( Connection con )throws SQLException;
  +
  +   /**
  +   * Provide a mechinism to return a connection to the pool on Error.
  +   * A good default behaviour is to close this connection and build
  +   * a new one to replace it. Some JDBC impl's won't allow you to
  +   * reuse a connection after an error occurs.
  +   * @param con
      * @return
      * @throws SQLException
      */
  -  public void releaseConnection( Connection con )throws SQLException         
;
  +  public void releaseConnectionOnError( Connection con )throws SQLException;
   
   
     /**
      * The Pool can be Enabled and Disabled. Disabling the pool
      * closes all the outstanding Unused connections and any new
      * connections will be closed upon release.
  -   * @param flag Control the Connection Pool. If it is enabled then 
Connections will actuall be held
  -   * around. If disabled then all unused connections will be instantly 
closed and as
  +   * @param flag Control the Connection Pool. If it is enabled
  +   * then Connections will actuall be held around. If disabled
  +   * then all unused connections will be instantly closed and as
      * connections are released they are closed and removed from the pool.
      * @return
      */
     public void setPoolEnabled( final boolean flag );
  -  
  -  
  +
  +
   }
  
  
  
  1.3       +2 -12     
xml-xalan/java/src/org/apache/xalan/lib/sql/ConnectionPoolManager.java
  
  Index: ConnectionPoolManager.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/ConnectionPoolManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionPoolManager.java        2001/07/28 00:25:57     1.2
  +++ ConnectionPoolManager.java        2001/08/01 02:38:30     1.3
  @@ -60,13 +60,12 @@
   
   import java.util.Hashtable;
   import java.lang.IllegalArgumentException;
  -
   import org.apache.xalan.res.XSLMessages;
   import org.apache.xalan.res.XSLTErrorResources;
   
   /**
    */
  -public class ConnectionPoolManager    
  +public class ConnectionPoolManager
   {
     /**
      */
  @@ -108,14 +107,10 @@
      * @param name
      * @param pool
      * @return
  +   * @link org.apache.xalan.lib.sql.ConnectionPool}
      * @return
      * @throws <code>IllegalArgumentException</code>, throw this exception
      * if a pool with the same name currently exists.
  -   * @return
  -   * @return
  -   * @return
  -   * @return
  -   * @link org.apache.xalan.lib.sql.ConnectionPool}
      */
     public synchronized void registerPool( String name, ConnectionPool pool )
     {
  @@ -160,11 +155,6 @@
     /**
      * Return the connection pool referenced by the name
      * @param name
  -   * @return
  -   * @return
  -   * @return
  -   * @return
  -   * @return
      * @return
      * @returns <code>ConnectionPool</code> a reference to the ConnectionPool
      * object stored in the Pool Table. If the named pool does not exist, 
return
  
  
  
  1.2       +423 -104  
xml-xalan/java/src/org/apache/xalan/lib/sql/DTMDocument.java
  
  Index: DTMDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/DTMDocument.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DTMDocument.java  2001/07/30 17:36:53     1.1
  +++ DTMDocument.java  2001/08/01 02:38:30     1.2
  @@ -66,25 +66,25 @@
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMAxisTraverser;
   import org.apache.xml.dtm.DTMAxisIterator;
  -
  -
   import org.apache.xml.utils.XMLString;
   import org.apache.xml.utils.XMLStringFactory;
   import org.apache.xml.utils.SuballocatedIntVector;
   import org.w3c.dom.Node;
  -
   import org.xml.sax.ext.DeclHandler;
   import org.xml.sax.ErrorHandler;
   import org.xml.sax.DTDHandler;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.ext.LexicalHandler;
   import org.xml.sax.ContentHandler;
  -
  -// Needed for our version of dumpDTM
   import java.io.IOException;
   import java.io.File;
   import java.io.PrintStream;
   import java.io.FileOutputStream;
  +import org.xml.sax.*;
  +import javax.xml.transform.SourceLocator;
  +import org.apache.xml.utils.*;
  +import org.apache.xml.dtm.*;
  +import org.xml.sax.ext.*;
   
   /**
    * The SQL Document is the main controlling class the executesa SQL Query
  @@ -92,26 +92,52 @@
   public class DTMDocument extends DTMDefaultBaseIterators
   {
   
  +  /**
  +   */
     public interface CharacterNodeHandler
     {
  -    public void characters(Node node)
  -            throws org.xml.sax.SAXException;
  +    /**
  +     * @param node
  +     * @return
  +     * @throws org.xml.sax.SAXException
  +     */
  +    public void characters( Node node )throws org.xml.sax.SAXException ;
     }
   
  +  /**
  +   */
     private boolean DEBUG = false;
   
  +  /**
  +   */
     protected static final String S_NAMESPACE = 
"http://xml.apache.org/xalan/SQLExtension";;
   
  -  protected static final String S_ATTRIB_NOT_SUPPORTED="Not Supported";
  -  protected static final String S_ISTRUE="true";
  -  protected static final String S_ISFALSE="false";
  +  /**
  +   */
  +  protected static final String S_ATTRIB_NOT_SUPPORTED = "Not Supported";
  +  /**
  +   */
  +  protected static final String S_ISTRUE = "true";
  +  /**
  +   */
  +  protected static final String S_ISFALSE = "false";
   
  +  /**
  +   */
     protected static final String S_DOCUMENT = "#root";
  +  /**
  +   */
     protected static final String S_TEXT_NODE = "#text";
  -  protected static final String S_ELEMENT_NODE   = "#element";
  +  /**
  +   */
  +  protected static final String S_ELEMENT_NODE = "#element";
   
  -  protected int         m_Document_TypeID = 0;
  -  protected int         m_TextNode_TypeID = 0;
  +  /**
  +   */
  +  protected int m_Document_TypeID = 0;
  +  /**
  +   */
  +  protected int m_TextNode_TypeID = 0;
   
   
     /**
  @@ -133,10 +159,14 @@
      * The Document Index will most likely be 0, but we will reference it
      * by variable in case that paradigm falls through.
      */
  -  protected int       m_DocumentIdx;
  +  protected int m_DocumentIdx;
   
   
  -  public DTMDocument(DTMManager mgr, int ident)
  +  /**
  +   * @param mgr
  +   * @param ident
  +   */
  +  public DTMDocument( DTMManager mgr, int ident )
     {
       super(mgr, null, ident,
         null, mgr.getXMLStringFactory(), true);
  @@ -148,15 +178,25 @@
      * A common routine that allocates an Object from the Object Array.
      * One of the common bugs in this code was to allocate an Object and
      * not incerment m_size, using this method will assure that function.
  +   * @param o
  +   * @return
      */
  -  private int allocateNodeObject(Object o)
  +  private int allocateNodeObject( Object o )
     {
       // Need to keep this counter going even if we don't use it.
       m_size++;
       return m_ObjectArray.append(o);
     }
   
  -  protected int addElementWithData(Object o, int level, int extendedType, 
int parent, int prevsib)
  +  /**
  +   * @param o
  +   * @param level
  +   * @param extendedType
  +   * @param parent
  +   * @param prevsib
  +   * @return
  +   */
  +  protected int addElementWithData( Object o, int level, int extendedType, 
int parent, int prevsib )
     {
       int elementIdx = addElement(level,extendedType,parent,prevsib);
   
  @@ -175,7 +215,14 @@
       return elementIdx;
     }
   
  -  protected int addElement(int level, int extendedType, int parent, int 
prevsib)
  +  /**
  +   * @param level
  +   * @param extendedType
  +   * @param parent
  +   * @param prevsib
  +   * @return
  +   */
  +  protected int addElement( int level, int extendedType, int parent, int 
prevsib )
     {
       int node = DTM.NULL;
   
  @@ -228,10 +275,12 @@
      * The first attribute is attached to the Parent Node (pnode) through the
      * m_attribute array, subsequent attributes are linked through the
      * m_prevsib, m_nextsib arrays.
  -   *
  +   * @param o
  +   * @param extendedType
  +   * @param pnode
  +   * @return
      */
  -  protected int addAttributeToNode(
  -    Object o, int extendedType, int pnode)
  +  protected int addAttributeToNode( Object o, int extendedType, int pnode )
     {
       int attrib = DTM.NULL;
       int prevsib = DTM.NULL;
  @@ -281,8 +330,11 @@
      * problems because the parent of any attribute will be the original node
      * they were assigned to. Need to see how the attribute walker works, then
      * we should be able to fake it out.
  +   * @param toNode
  +   * @param fromNode
  +   * @return
      */
  -  protected void cloneAttributeFromNode(int toNode, int fromNode)
  +  protected void cloneAttributeFromNode( int toNode, int fromNode )
     {
      try
       {
  @@ -300,7 +352,11 @@
     }
   
   
  -  public int getFirstAttribute(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getFirstAttribute( int parm1 )
     {
       if (DEBUG) System.out.println("getFirstAttribute("+ 
(parm1&NODEIDENTITYBITS)+")");
       int nodeIdx = parm1 & NODEIDENTITYBITS;
  @@ -362,7 +418,11 @@
     }
   
   
  -  public int getNextAttribute(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getNextAttribute( int parm1 )
     {
       if (DEBUG) System.out.println("getNextAttribute(" + parm1 + ")");
       int nodeIdx = parm1 & NODEIDENTITYBITS;
  @@ -389,8 +449,27 @@
       return false;
     }
   
  +
  +  /**
  +   * The Expanded Name table holds all of our Node names. The Base class
  +   * will add the common element types, need to call this function from
  +   * the derived class.
  +   * @return
  +   */
  +  protected void createExpandedNameTable( )
  +  {
  +    m_Document_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_DOCUMENT, 
DTM.DOCUMENT_NODE);
  +
  +    m_TextNode_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_TEXT_NODE, 
DTM.TEXT_NODE);
  +  }
  +
   
  -  public void dumpDTM()
  +  /**
  +   * @return
  +   */
  +  public void dumpDTM( )
     {
       try
       {
  @@ -543,16 +622,14 @@
      * routine _shouldn't_ perform any processing beyond what the DOM already
      * does, and that whitespace stripping and so on belong at the DTM level.
      * If you want a stripped DOM view, wrap DTM2DOM around DOM2DTM.
  -   *
      * @param node Node whose subtree is to be walked, gathering the
      * contents of all Text or CDATASection nodes.
  -   * @param buf FastStringBuffer into which the contents of the text
  -   * nodes are to be concatenated.
  +   * @param ch
  +   * @param depth
  +   * @return
  +   * @throws org.xml.sax.SAXException
      */
  -  protected static void dispatchNodeData(Node node,
  -                                         org.xml.sax.ContentHandler ch,
  -                                         int depth)
  -            throws org.xml.sax.SAXException
  +  protected static void dispatchNodeData( Node node, ContentHandler ch, int 
depth )throws org.xml.sax.SAXException 
     {
   
       switch (node.getNodeType())
  @@ -606,22 +683,21 @@
     /**
      * For the moment all the run time properties are ignored by this
      * class.
  -   *
      * @param property a <code>String</code> value
      * @param value an <code>Object</code> value
  +   * @return
      */
  -  public void setProperty(String property, Object value)
  +  public void setProperty( String property, Object value )
     {
     }
   
     /**
      * No source information is available for DOM2DTM, so return
      * <code>null</code> here.
  -   *
      * @param node an <code>int</code> value
      * @return null
      */
  -  public javax.xml.transform.SourceLocator getSourceLocatorFor(int node)
  +  public SourceLocator getSourceLocatorFor( int node )
     {
       return null;
     }
  @@ -779,9 +855,10 @@
      * @param parm2
      * @return
      * @throws org.xml.sax.SAXException
  +   * @return
  +   * @throws org.xml.sax.SAXException
      */
  -  public void dispatchToEvents( int parm1, ContentHandler parm2 )
  -    throws org.xml.sax.SAXException
  +  public void dispatchToEvents( int parm1, ContentHandler parm2 )throws 
org.xml.sax.SAXException 
     {
       if (DEBUG)
       {
  @@ -804,16 +881,15 @@
     }
   
     /**
  -   * @param parm1
  -   * @param parm2
  -   * @param parm3
  +   * @param nodeHandle
  +   * @param ch
  +   * @param normalize
      * @return
      * @throws org.xml.sax.SAXException
  +   * @return
  +   * @throws org.xml.sax.SAXException
      */
  -  public void dispatchCharactersEvents(
  -          int nodeHandle, org.xml.sax.ContentHandler ch,
  -          boolean normalize)
  -            throws org.xml.sax.SAXException
  +  public void dispatchCharactersEvents( int nodeHandle, ContentHandler ch, 
boolean normalize )throws org.xml.sax.SAXException 
     {
       if (DEBUG)
       {
  @@ -839,58 +915,90 @@
   
     /**
      * Event overriding for Debug
  +   * @return
      */
  -
  -  public boolean supportsPreStripping()
  +  public boolean supportsPreStripping( )
     {
       if (DEBUG) System.out.println("supportsPreStripping()");
       return super.supportsPreStripping();
     }
   
  -  protected int _exptype(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _exptype( int parm1 )
     {
       if (DEBUG) System.out.println("_exptype(" + parm1 + ")");
       return super._exptype( parm1);
     }
   
  -  protected SuballocatedIntVector findNamespaceContext(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected SuballocatedIntVector findNamespaceContext( int parm1 )
     {
       if (DEBUG) System.out.println("SuballocatedIntVector(" + parm1 + ")");
       return super.findNamespaceContext( parm1);
     }
   
  -  protected int _prevsib(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _prevsib( int parm1 )
     {
       if (DEBUG) System.out.println("_prevsib(" + parm1+ ")");
       return super._prevsib( parm1);
     }
   
   
  -  protected short _type(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected short _type( int parm1 )
     {
       if (DEBUG) System.out.println("_type(" + parm1 + ")");
       return super._type( parm1);
     }
   
  -  public Node getNode(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public Node getNode( int parm1 )
     {
       if (DEBUG) System.out.println("getNode(" + parm1 + ")");
       return super.getNode( parm1);
     }
   
  -  public int getPreviousSibling(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getPreviousSibling( int parm1 )
     {
       if (DEBUG) System.out.println("getPrevSib(" + parm1 + ")");
       return super.getPreviousSibling( parm1);
     }
   
  -  public String getDocumentStandalone(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getDocumentStandalone( int parm1 )
     {
       if (DEBUG) System.out.println("getDOcStandAlone(" + parm1 + ")");
       return super.getDocumentStandalone( parm1);
     }
   
  -  public String getNodeNameX(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getNodeNameX( int parm1 )
     {
       if (DEBUG) System.out.println("getNodeNameX(" + parm1 + ")");
       //return super.getNodeNameX( parm1);
  @@ -898,7 +1006,12 @@
   
     }
   
  -  public void setFeature(String parm1, boolean parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  public void setFeature( String parm1, boolean parm2 )
     {
       if (DEBUG)
       {
  @@ -910,82 +1023,136 @@
       super.setFeature( parm1,  parm2);
     }
   
  -  protected int _parent(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _parent( int parm1 )
     {
       if (DEBUG) System.out.println("_parent(" + parm1 + ")");
       return super._parent( parm1);
     }
   
  -  protected void indexNode(int parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  protected void indexNode( int parm1, int parm2 )
     {
       if (DEBUG) System.out.println("indexNode("+parm1+","+parm2+")");
       super.indexNode( parm1,  parm2);
     }
   
  -  protected boolean getShouldStripWhitespace()
  +  /**
  +   * @return
  +   */
  +  protected boolean getShouldStripWhitespace( )
     {
       if (DEBUG) System.out.println("getShouldStripWS()");
       return super.getShouldStripWhitespace();
     }
   
  -  protected void popShouldStripWhitespace()
  +  /**
  +   * @return
  +   */
  +  protected void popShouldStripWhitespace( )
     {
       if (DEBUG) System.out.println("popShouldStripWS()");
       super.popShouldStripWhitespace();
     }
   
  -  public boolean isNodeAfter(int parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  public boolean isNodeAfter( int parm1, int parm2 )
     {
       if (DEBUG) System.out.println("isNodeAfter(" + parm1 + "," + parm2 + 
")");
       return super.isNodeAfter( parm1,  parm2);
     }
   
  -  public int getNamespaceType(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getNamespaceType( int parm1 )
     {
       if (DEBUG) System.out.println("getNamespaceType(" + parm1 + ")");
       return super.getNamespaceType( parm1);
     }
   
  -  protected int _level(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _level( int parm1 )
     {
       if (DEBUG) System.out.println("_level(" + parm1 + ")");
       return super._level( parm1);
     }
   
   
  -  protected void pushShouldStripWhitespace(boolean parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected void pushShouldStripWhitespace( boolean parm1 )
     {
       if (DEBUG) System.out.println("push_ShouldStripWS(" + parm1 + ")");
       super.pushShouldStripWhitespace( parm1);
     }
   
  -  public String getDocumentVersion(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getDocumentVersion( int parm1 )
     {
       if (DEBUG) System.out.println("getDocVer("+parm1+")");
       return super.getDocumentVersion( parm1);
     }
   
  -  public boolean isSupported(String parm1, String parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  public boolean isSupported( String parm1, String parm2 )
     {
       if (DEBUG) System.out.println("isSupported("+parm1+","+parm2+")");
       return super.isSupported( parm1,  parm2);
     }
   
   
  -  protected void setShouldStripWhitespace(boolean parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected void setShouldStripWhitespace( boolean parm1 )
     {
       if (DEBUG) System.out.println("set_ShouldStripWS("+parm1+")");
       super.setShouldStripWhitespace( parm1);
     }
   
   
  -  protected void ensureSizeOfIndex(int parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  protected void ensureSizeOfIndex( int parm1, int parm2 )
     {
       if (DEBUG) System.out.println("ensureSizeOfIndex("+parm1+","+parm2+")");
       super.ensureSizeOfIndex( parm1,  parm2);
     }
   
  -  protected void ensureSize(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected void ensureSize( int parm1 )
     {
       if (DEBUG) System.out.println("ensureSize("+parm1+")");
   
  @@ -994,13 +1161,23 @@
       //super.ensureSize( parm1);
     }
   
  -  public String getDocumentEncoding(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getDocumentEncoding( int parm1 )
     {
       if (DEBUG) System.out.println("getDocumentEncoding("+parm1+")");
       return super.getDocumentEncoding( parm1);
     }
   
  -  public void appendChild(int parm1, boolean parm2, boolean parm3)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @param parm3
  +   * @return
  +   */
  +  public void appendChild( int parm1, boolean parm2, boolean parm3 )
     {
       if (DEBUG)
       {
  @@ -1013,19 +1190,32 @@
       super.appendChild( parm1,  parm2,  parm3);
     }
   
  -  public short getLevel(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public short getLevel( int parm1 )
     {
       if (DEBUG) System.out.println("getLevel("+parm1+")");
       return super.getLevel( parm1);
     }
   
  -  public String getDocumentBaseURI()
  +  /**
  +   * @return
  +   */
  +  public String getDocumentBaseURI( )
     {
       if (DEBUG) System.out.println("getDocBaseURI()");
       return super.getDocumentBaseURI();
     }
   
  -  public int getNextNamespaceNode(int parm1, int parm2, boolean parm3)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @param parm3
  +   * @return
  +   */
  +  public int getNextNamespaceNode( int parm1, int parm2, boolean parm3 )
     {
       if (DEBUG)
       {
  @@ -1038,13 +1228,24 @@
       return super.getNextNamespaceNode( parm1,  parm2,  parm3);
     }
   
  -  public void appendTextChild(String parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public void appendTextChild( String parm1 )
     {
       if (DEBUG) System.out.println("appendTextChild(" + parm1 + ")");
       super.appendTextChild( parm1);
     }
   
  -  protected int findGTE(int[] parm1, int parm2, int parm3, int parm4)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @param parm3
  +   * @param parm4
  +   * @return
  +   */
  +  protected int findGTE( int[] parm1, int parm2, int parm3, int parm4 )
     {
       if (DEBUG)
       {
  @@ -1057,31 +1258,52 @@
       return super.findGTE( parm1,  parm2,  parm3,  parm4);
     }
   
  -  public int getFirstNamespaceNode(int parm1, boolean parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  public int getFirstNamespaceNode( int parm1, boolean parm2 )
     {
       if (DEBUG) System.out.println("getFirstNamespaceNode()");
       return super.getFirstNamespaceNode( parm1,  parm2);
     }
   
  -  public int getStringValueChunkCount(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getStringValueChunkCount( int parm1 )
     {
       if (DEBUG) System.out.println("getStringChunkCount(" + parm1 + ")");
       return super.getStringValueChunkCount( parm1);
     }
   
  -  public int getLastChild(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getLastChild( int parm1 )
     {
       if (DEBUG) System.out.println("getLastChild(" + parm1 + ")");
       return super.getLastChild( parm1);
     }
   
  -  public boolean hasChildNodes(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public boolean hasChildNodes( int parm1 )
     {
       if (DEBUG) System.out.println("hasChildNodes(" + parm1 + ")");
       return super.hasChildNodes( parm1);
     }
   
  -  public short getNodeType(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public short getNodeType( int parm1 )
     {
       if (DEBUG)
       {
  @@ -1099,31 +1321,52 @@
       return super.getNodeType( parm1);
     }
   
  -  public boolean isCharacterElementContentWhitespace(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public boolean isCharacterElementContentWhitespace( int parm1 )
     {
       if (DEBUG) System.out.println("isCharacterElementContentWhitespace(" + 
parm1 +")");
       return super.isCharacterElementContentWhitespace( parm1);
     }
   
  -  public int getFirstChild(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getFirstChild( int parm1 )
     {
       if (DEBUG) System.out.println("getFirstChild(" + parm1 + ")");
       return super.getFirstChild( parm1);
     }
   
  -  public String getDocumentSystemIdentifier(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getDocumentSystemIdentifier( int parm1 )
     {
       if (DEBUG) System.out.println("getDocSysID(" + parm1 + ")");
       return super.getDocumentSystemIdentifier( parm1);
     }
   
  -  protected void declareNamespaceInContext(int parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  protected void declareNamespaceInContext( int parm1, int parm2 )
     {
       if (DEBUG) 
System.out.println("declareNamespaceContext("+parm1+","+parm2+")");
       super.declareNamespaceInContext( parm1,  parm2);
     }
   
  -  public String getNamespaceFromExpandedNameID(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getNamespaceFromExpandedNameID( int parm1 )
     {
       if (DEBUG)
       {
  @@ -1135,7 +1378,11 @@
       return super.getNamespaceFromExpandedNameID( parm1);
     }
   
  -  public String getLocalNameFromExpandedNameID(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public String getLocalNameFromExpandedNameID( int parm1 )
     {
       if (DEBUG)
       {
  @@ -1147,20 +1394,32 @@
       return super.getLocalNameFromExpandedNameID( parm1);
     }
   
  -  public int getExpandedTypeID(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getExpandedTypeID( int parm1 )
     {
       if (DEBUG) System.out.println("getExpandedTypeID("+parm1+")");
       return super.getExpandedTypeID( parm1);
     }
   
  -  public int getDocument()
  +  /**
  +   * @return
  +   */
  +  public int getDocument( )
     {
       if (DEBUG) System.out.println("getDocument()");
       return super.getDocument();
     }
   
   
  -  protected int findInSortedSuballocatedIntVector(SuballocatedIntVector 
parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  protected int findInSortedSuballocatedIntVector( SuballocatedIntVector 
parm1, int parm2 )
     {
       if (DEBUG)
       {
  @@ -1172,69 +1431,116 @@
       return super.findInSortedSuballocatedIntVector( parm1,  parm2);
     }
   
  -  public boolean isDocumentAllDeclarationsProcessed(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public boolean isDocumentAllDeclarationsProcessed( int parm1 )
     {
       if (DEBUG) System.out.println("isDocumentAllDeclProc("+parm1+")");
       return super.isDocumentAllDeclarationsProcessed( parm1);
     }
   
  -  protected void error(String parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected void error( String parm1 )
     {
       if (DEBUG) System.out.println("error("+parm1+")");
       super.error( parm1);
     }
   
   
  -  protected int _firstch(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _firstch( int parm1 )
     {
       if (DEBUG) System.out.println("_firstch("+parm1+")");
       return super._firstch( parm1);
     }
   
  -  public int getOwnerDocument(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getOwnerDocument( int parm1 )
     {
       if (DEBUG) System.out.println("getOwnerDoc("+parm1+")");
       return super.getOwnerDocument( parm1);
     }
   
  -  protected int _nextsib(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  protected int _nextsib( int parm1 )
     {
       if (DEBUG) System.out.println("_nextSib("+parm1+")");
       return super._nextsib( parm1);
     }
   
  -  public int getNextSibling(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getNextSibling( int parm1 )
     {
       if (DEBUG) System.out.println("getNextSibling("+parm1+")");
       return super.getNextSibling( parm1);
     }
   
   
  -  public boolean getDocumentAllDeclarationsProcessed()
  +  /**
  +   * @return
  +   */
  +  public boolean getDocumentAllDeclarationsProcessed( )
     {
       if (DEBUG) System.out.println("getDocAllDeclProc()");
       return super.getDocumentAllDeclarationsProcessed();
     }
   
  -  public int getParent(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public int getParent( int parm1 )
     {
       if (DEBUG) System.out.println("getParent("+parm1+")");
       return super.getParent( parm1);
     }
   
  -  public int getExpandedTypeID(String parm1, String parm2, int parm3)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @param parm3
  +   * @return
  +   */
  +  public int getExpandedTypeID( String parm1, String parm2, int parm3 )
     {
       if (DEBUG) System.out.println("getExpandedTypeID()");
       return super.getExpandedTypeID( parm1,  parm2,  parm3);
     }
   
  -  public void setDocumentBaseURI(String parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public void setDocumentBaseURI( String parm1 )
     {
       if (DEBUG) System.out.println("setDocBaseURI()");
       super.setDocumentBaseURI( parm1);
     }
   
  -  public char[] getStringValueChunk(int parm1, int parm2, int[] parm3)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @param parm3
  +   * @return
  +   */
  +  public char[] getStringValueChunk( int parm1, int parm2, int[] parm3 )
     {
       if (DEBUG)
       {
  @@ -1245,19 +1551,32 @@
       return super.getStringValueChunk( parm1,  parm2,  parm3);
     }
   
  -  public DTMAxisTraverser getAxisTraverser(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public DTMAxisTraverser getAxisTraverser( int parm1 )
     {
       if (DEBUG) System.out.println("getAxixTraverser("+parm1+")");
       return super.getAxisTraverser( parm1);
     }
   
  -  public DTMAxisIterator getTypedAxisIterator(int parm1, int parm2)
  +  /**
  +   * @param parm1
  +   * @param parm2
  +   * @return
  +   */
  +  public DTMAxisIterator getTypedAxisIterator( int parm1, int parm2 )
     {
       if (DEBUG) 
System.out.println("getTypedAxisIterator("+parm1+","+parm2+")");
       return super.getTypedAxisIterator( parm1,  parm2);
     }
   
  -  public DTMAxisIterator getAxisIterator(int parm1)
  +  /**
  +   * @param parm1
  +   * @return
  +   */
  +  public DTMAxisIterator getAxisIterator( int parm1 )
     {
       if (DEBUG) System.out.println("getAxisIterator("+parm1+")");
       return super.getAxisIterator( parm1);
  
  
  
  1.8       +47 -81    
xml-xalan/java/src/org/apache/xalan/lib/sql/DefaultConnectionPool.java
  
  Index: DefaultConnectionPool.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/DefaultConnectionPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultConnectionPool.java        2001/07/12 05:01:44     1.7
  +++ DefaultConnectionPool.java        2001/08/01 02:38:30     1.8
  @@ -68,8 +68,10 @@
   import java.sql.*;
   
   /**
  + * For internal connectiones, i.e. Connection information supplies in the
  + * Stylesheet. The Default Connection Pool will be used.
    */
  -public class DefaultConnectionPool  implements ConnectionPool
  +public class DefaultConnectionPool implements ConnectionPool
   {
     /**
      */
  @@ -114,27 +116,7 @@
      */
     public DefaultConnectionPool( ) {}
   
  -  ///**
  -//   * Are we active, if not then released connections will be
  -//   * closed on release and new connections will be refused.
  -//   * @return
  -//   */
  -//  public void disablePool( )
  -//  {
  -//    m_IsActive = false;
  -//    freeUnused();
  -//  }
  -
  -  
  -  ///**
  -//   * @return
  -//   */
  -//  public void enablePool( )
  -//  {
  -//    m_IsActive = true;
  -//  }
   
  -  
     /**
      * Return our current Active state
      * @return
  @@ -224,7 +206,7 @@
       m_ConnectionProtocol.put("user", u);
     }
   
  -  ///**
  +///**
   //   * Copy the properties from the source to our properties
   //   * @param p
   //   * @return
  @@ -241,7 +223,7 @@
   //
   //  }
   
  -  
  +
     /**
      * Override the current number of connections to keep in the pool. This
      * setting will only have effect on a new pool or when a new connection
  @@ -308,21 +290,11 @@
   
     // Find an available connection
     /**
  -   * @return
  +   * @return Connection
      * @throws SQLException
      * @throws IllegalArgumentException
  -   * @return
  -   * @throws IllegalArgumentException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws IllegalArgumentException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws IllegalArgumentException
      */
  -  public synchronized Connection getConnection( )throws 
IllegalArgumentException, SQLException          
  +  public synchronized Connection getConnection( )throws 
IllegalArgumentException, SQLException
     {
   
       PooledConnection pcon = null;
  @@ -374,18 +346,8 @@
      * @param con
      * @return
      * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
      */
  -  public synchronized void releaseConnection( Connection con )throws 
SQLException          
  +  public synchronized void releaseConnection( Connection con )throws 
SQLException
     {
   
       // find the PooledConnection Object
  @@ -426,22 +388,46 @@
     }
   
   
  -
     /**
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws SQLException
  +   * @param con
      * @return
      * @throws SQLException
  +   */
  +  public synchronized void releaseConnectionOnError( Connection con )throws 
SQLException
  +  {
  +
  +    // find the PooledConnection Object
  +    for ( int x = 0; x < m_pool.size(); x++ )
  +    {
  +
  +      PooledConnection pcon =
  +        (PooledConnection) m_pool.elementAt(x);
  +
  +      // Check for correct Connection
  +      if ( pcon.getConnection() == con )
  +      {
  +        if (DEBUG)
  +        {
  +          System.out.println("Releasing Connection On Error" + x);
  +        }
  +
  +        con.close();
  +        m_pool.removeElementAt(x);
  +        if (DEBUG)
  +        {
  +          System.out.println("-->Inactive Pool, Closing connection");
  +        }
  +        break;
  +      }
  +    }
  +  }
  +
  +
  +  /**
      * @return
      * @throws SQLException
      */
  -  private Connection createConnection( )throws SQLException          
  +  private Connection createConnection( )throws SQLException
     {
       Connection con = null;
   
  @@ -454,20 +440,10 @@
     // Initialize the pool
     /**
      * @return
  -   * @throws SQLException
      * @throws IllegalArgumentException
  -   * @return
  -   * @throws IllegalArgumentException
  -   * @return
      * @throws SQLException
  -   * @return
  -   * @throws IllegalArgumentException
  -   * @return
  -   * @throws SQLException
  -   * @return
  -   * @throws IllegalArgumentException
      */
  -  public synchronized void initializePool( )throws IllegalArgumentException, 
SQLException          
  +  public synchronized void initializePool( )throws IllegalArgumentException, 
SQLException
     {
   
        // Check our initial values
  @@ -539,18 +515,8 @@
     /**
      * @return
      * @throws Throwable
  -   * @return
  -   * @throws Throwable
  -   * @return
  -   * @throws Throwable
  -   * @return
  -   * @throws Throwable
  -   * @return
  -   * @throws Throwable
  -   * @return
  -   * @throws Throwable
      */
  -  protected void finalize( )throws Throwable          
  +  protected void finalize( )throws Throwable
     {
       if (DEBUG)
       {
  @@ -612,8 +578,8 @@
      */
     public void setPoolEnabled( final boolean flag )
     {
  -    
  +
     }
  -  
  -  
  +
  +
   }
  
  
  
  1.4       +28 -11    
xml-xalan/java/src/org/apache/xalan/lib/sql/ObjectArray.java
  
  Index: ObjectArray.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/ObjectArray.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ObjectArray.java  2001/07/30 17:34:51     1.3
  +++ ObjectArray.java  2001/08/01 02:38:30     1.4
  @@ -3,13 +3,16 @@
   import java.util.Vector;
   
   /**
  - * Provide a simple Array storage mechinsim where  native Arrays will be use 
as the basic storage mechinism but the Arrays will be stored as blocks. The 
size of the
  - * Array blocks is determine during object construction. This is intended to 
be a
  - * simple storage mechinsim where the storage only can grow. Array elements 
can
  - * not be removed, only added to.
  + * Provide a simple Array storage mechinsim where  native Arrays will be use 
as
  + * the basic storage mechinism but the Arrays will be stored as blocks.
  + * The size of the Array blocks is determine during object construction.
  + * This is intended to be a simple storage mechinsim where the storage only
  + * can grow. Array elements can not be removed, only added to.
    */
   public class ObjectArray
   {
  +  /**
  +   */
     private int m_minArraySize = 10;
     /**
      * The container of all the sub arrays
  @@ -30,9 +33,8 @@
   
   
     /**
  -   * @param minArraySize The size of the Arrays stored in the Vector
      */
  -  public ObjectArray()
  +  public ObjectArray( )
     {
       //
       // Default constructor will work with a minimal fixed size
  @@ -48,7 +50,11 @@
       init(minArraySize);
     }
   
  -  private void init(int size)
  +  /**
  +   * @param size
  +   * @return
  +   */
  +  private void init( int size )
     {
       m_minArraySize = size;
       m_currentArray = new _ObjectArray(m_minArraySize);
  @@ -84,7 +90,7 @@
   
     /**
      * @param idx Index of the Object in the Array
  -   * @param obj, The value to set in the Array
  +   * @param obj , The value to set in the Array
      * @return
      */
     public void setAt( final int idx, final Object obj )
  @@ -136,16 +142,27 @@
     }
   
   
  -  protected class _ObjectArray
  +  /**
  +   */
  +  class _ObjectArray
     {
  +    /**
  +     */
       public Object[] objects;
  -    public _ObjectArray(int size)
  +    /**
  +     * @param size
  +     */
  +    public _ObjectArray( int size )
       {
         objects = new Object[size];
       }
     }
   
  -  public static void main(String[] args)
  +  /**
  +   * @param args
  +   * @return
  +   */
  +  public static void main( String[] args )
     {
       String[] word={
         "Zero","One","Two","Three","Four","Five",
  
  
  
  1.7       +7 -6      
xml-xalan/java/src/org/apache/xalan/lib/sql/PooledConnection.java
  
  Index: PooledConnection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/PooledConnection.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PooledConnection.java     2001/07/12 05:01:47     1.6
  +++ PooledConnection.java     2001/08/01 02:38:30     1.7
  @@ -61,7 +61,7 @@
   
   /**
    */
  -public class PooledConnection          
  +public class PooledConnection
   {
   
     // Real JDBC Connection
  @@ -83,9 +83,9 @@
       if ( value != null ) { connection = value; }
     }
   
  -  // Returns a reference to the JDBC Connection
     /**
  -   * @return
  +   * Returns a reference to the JDBC Connection
  +   * @return Connection
      */
     public Connection getConnection( )
     {
  @@ -93,8 +93,9 @@
       return connection;
     }
   
  -  // Set the status of the PooledConnection.
     /**
  +   * Set the status of the PooledConnection.
  +   *
      * @param value
      * @return
      */
  @@ -103,14 +104,14 @@
       inuse = value;
     }
   
  -  // Returns the current status of the PooledConnection.
     /**
  +   * Returns the current status of the PooledConnection.
      * @return
      */
     public boolean inUse( ) { return inuse; }
   
  -  // Close the real JDBC Connection
     /**
  +   *  Close the real JDBC Connection
      * @return
      */
     public void close( )
  
  
  
  1.14      +177 -75   
xml-xalan/java/src/org/apache/xalan/lib/sql/SQLDocument.java
  
  Index: SQLDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/SQLDocument.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- SQLDocument.java  2001/07/30 17:34:51     1.13
  +++ SQLDocument.java  2001/08/01 02:38:30     1.14
  @@ -60,15 +60,14 @@
   
   package org.apache.xalan.lib.sql;
   
  -
   import org.apache.xml.dtm.DTMManager;
   import org.apache.xml.dtm.DTM;
  -
   import java.sql.Connection;
   import java.sql.Statement;
   import java.sql.ResultSet;
   import java.sql.ResultSetMetaData;
   import java.sql.SQLException;
  +import java.sql.*;
   
   /**
    * The SQL Document is the main controlling class the executesa SQL Query
  @@ -76,61 +75,145 @@
   public class SQLDocument extends DTMDocument
   {
   
  -  private boolean DEBUG = true;
  +  /**
  +   */
  +  private boolean DEBUG = false;
   
  +  /**
  +   */
     private static final String S_NAMESPACE = 
"http://xml.apache.org/xalan/SQLExtension";;
   
   
  +  /**
  +   */
     private static final String S_COLUMN_HEADER = "column-header";
  +  /**
  +   */
     private static final String S_ROW_SET = "row-set";
  +  /**
  +   */
     private static final String S_ROW = "row";
  +  /**
  +   */
     private static final String S_COL = "col";
   
  +  /**
  +   */
     private static final String S_CATALOGUE_NAME = "catalogue-name";
  +  /**
  +   */
     private static final String S_DISPLAY_SIZE = "column-display-size";
  +  /**
  +   */
     private static final String S_COLUMN_LABEL = "column-label";
  +  /**
  +   */
     private static final String S_COLUMN_NAME = "column-name";
  +  /**
  +   */
     private static final String S_COLUMN_TYPE = "column-type";
  +  /**
  +   */
     private static final String S_COLUMN_TYPENAME = "column-typename";
  +  /**
  +   */
     private static final String S_PRECISION = "precision";
  +  /**
  +   */
     private static final String S_SCALE = "scale";
  +  /**
  +   */
     private static final String S_SCHEMA_NAME = "schema-name";
  +  /**
  +   */
     private static final String S_TABLE_NAME = "table-name";
  +  /**
  +   */
     private static final String S_CASESENSITIVE = "case-sensitive";
  +  /**
  +   */
     private static final String S_DEFINITLEYWRITABLE = "definitley-writable";
  +  /**
  +   */
     private static final String S_ISNULLABLE = "nullable";
  +  /**
  +   */
     private static final String S_ISSIGNED = "signed";
  +  /**
  +   */
     private static final String S_ISWRITEABLE = "writable";
  +  /**
  +   */
     private static final String S_ISSEARCHABLE = "searchable";
   
  -  private int         m_ColumnHeader_TypeID = 0;
  -  private int         m_RowSet_TypeID = 0;
  -  private int         m_Row_TypeID = 0;
  -  private int         m_Col_TypeID = 0;
  -
  -  private int         m_ColAttrib_CATALOGUE_NAME_TypeID = 0;
  -  private int         m_ColAttrib_DISPLAY_SIZE_TypeID = 0;
  -  private int         m_ColAttrib_COLUMN_LABEL_TypeID = 0;
  -  private int         m_ColAttrib_COLUMN_NAME_TypeID = 0;
  -  private int         m_ColAttrib_COLUMN_TYPE_TypeID = 0;
  -  private int         m_ColAttrib_COLUMN_TYPENAME_TypeID = 0;
  -  private int         m_ColAttrib_PRECISION_TypeID = 0;
  -  private int         m_ColAttrib_SCALE_TypeID = 0;
  -  private int         m_ColAttrib_SCHEMA_NAME_TypeID = 0;
  -  private int         m_ColAttrib_TABLE_NAME_TypeID = 0;
  -  private int         m_ColAttrib_CASESENSITIVE_TypeID = 0;
  -  private int         m_ColAttrib_DEFINITLEYWRITEABLE_TypeID = 0;
  -  private int         m_ColAttrib_ISNULLABLE_TypeID = 0;
  -  private int         m_ColAttrib_ISSIGNED_TypeID = 0;
  -  private int         m_ColAttrib_ISWRITEABLE_TypeID = 0;
  -  private int         m_ColAttrib_ISSEARCHABLE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColumnHeader_TypeID = 0;
  +  /**
  +   */
  +  private int m_RowSet_TypeID = 0;
  +  /**
  +   */
  +  private int m_Row_TypeID = 0;
  +  /**
  +   */
  +  private int m_Col_TypeID = 0;
   
     /**
  +   */
  +  private int m_ColAttrib_CATALOGUE_NAME_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_DISPLAY_SIZE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_COLUMN_LABEL_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_COLUMN_NAME_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_COLUMN_TYPE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_COLUMN_TYPENAME_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_PRECISION_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_SCALE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_SCHEMA_NAME_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_TABLE_NAME_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_CASESENSITIVE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_DEFINITLEYWRITEABLE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_ISNULLABLE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_ISSIGNED_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_ISWRITEABLE_TypeID = 0;
  +  /**
  +   */
  +  private int m_ColAttrib_ISSEARCHABLE_TypeID = 0;
  +
  +  /**
      * The DBMS Connection used to produce this SQL Document.
      * Will be used to clear free up the database resources on
      * close.
      */
  -  private Connection  m_Connection = null;
  +  private Connection m_Connection = null;
   
     /**
      * The Statement used to extract the data from the Database connection.
  @@ -139,63 +222,74 @@
      * is closed prior to reading all the data needed. So as long as we are
      * using the ResultSet, we will track the Statement used to produce it.
      */
  -  private Statement   m_Statement = null;
  +  private Statement m_Statement = null;
   
     /**
      * The conduit to our data that will be used to fill the document.
  +   */
  +  private ResultSet m_ResultSet = null;
  +
  +  /**
  +   * The Connection Pool that originally produced the connection.
      */
  -  private ResultSet   m_ResultSet = null;
  +  private ConnectionPool m_ConnectionPool = null;
  +
   
     /**
      * As the column header array is built, keep the node index
      * for each Column.
  -   *
      * The primary use of this is to locate the first attribute for
      * each column in each row as we add records.
      */
  -  private int[]     m_ColHeadersIdx;
  +  private int[] m_ColHeadersIdx;
   
     /**
      * An indicator on how many columns are in this query
      */
  -  private int       m_ColCount;
  +  private int m_ColCount;
     /**
      * The index of the Row Set node. This is the sibling directly after
      * the last Column Header.
      */
  -  private int       m_RowSetIdx = DTM.NULL;
  +  private int m_RowSetIdx = DTM.NULL;
   
     /**
      * Demark the first row element where we started adding rows into the
      * Document.
      */
  -  private int     m_FirstRowIdx = DTM.NULL;
  +  private int m_FirstRowIdx = DTM.NULL;
   
     /**
      * Keep track of the Last row inserted into the DTM from the ResultSet.
      * This will be used as the index of the parent Row Element when adding
      * a row.
      */
  -  private int     m_LastRowIdx = DTM.NULL;
  +  private int m_LastRowIdx = DTM.NULL;
   
     /**
      * Streaming Mode Control, In Streaming mode we reduce the memory
      * footprint since we only use a single row instance.
      */
  -
     private boolean m_StreamingMode = true;
   
  -  public SQLDocument(
  -    DTMManager mgr, int ident,
  -    Connection con, Statement stmt, ResultSet data,
  -    boolean streamingMode)
  -    throws SQLException
  +  /**
  +   * @param mgr
  +   * @param ident
  +   * @param pool
  +   * @param con
  +   * @param stmt
  +   * @param data
  +   * @param streamingMode
  +   * @throws SQLException
  +   */
  +  public SQLDocument( DTMManager mgr, int ident, ConnectionPool pool, 
Connection con, Statement stmt, ResultSet data, boolean streamingMode )throws 
SQLException 
     {
       super(mgr, ident);
   
       m_Connection = con;
       m_Statement  = stmt;
       m_ResultSet  = data;
  +    m_ConnectionPool = pool;
       m_StreamingMode = streamingMode;
   
       createExpandedNameTable();
  @@ -211,9 +305,10 @@
   
     /**
      * Extract the Meta Data and build the Column Attribute List.
  +   * @param meta
      * @return
      */
  -  private void extractSQLMetaData(ResultSetMetaData meta)
  +  private void extractSQLMetaData( ResultSetMetaData meta )
     {
       // Build the Node Tree, just add the Column Header
       // branch now, the Row & col elements will be added
  @@ -459,16 +554,11 @@
     /**
      * Populate the Expanded Name Table with the Node that we will use.
      * Keep a reference of each of the types for access speed.
  -   *
  +   * @return
      */
  -  private void createExpandedNameTable()
  +  protected void createExpandedNameTable( )
     {
  -
  -    m_Document_TypeID =
  -      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_DOCUMENT, 
DTM.DOCUMENT_NODE);
  -
  -    m_TextNode_TypeID =
  -      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_TEXT_NODE, 
DTM.TEXT_NODE);
  +    super.createExpandedNameTable();
   
       m_ColumnHeader_TypeID =
         m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_COLUMN_HEADER, 
DTM.ELEMENT_NODE);
  @@ -521,8 +611,9 @@
      * keep copying the data into the same row. This will keep the memory
      * footprint constint independant of the RecordSet Size. If we are not
      * in Streaming mode then create ROWS for the whole tree.
  +   * @return
      */
  -  private boolean addRowToDTMFromResultSet()
  +  private boolean addRowToDTMFromResultSet( )
     {
       try
       {
  @@ -631,39 +722,46 @@
     }
   
   
  -  public void close()
  +  /**
  +   * Clean up our ties to the database but this does not necessarly
  +   * clean up the document.
  +   * @return
  +   */
  +  public void close( )
     {
       if (DEBUG) System.out.println("close()");
   
  -    try
  -    {
  -      if (null != m_ResultSet) m_ResultSet.close();
  -    }
  -    catch(Exception e)
  -    {
  -      /* Empty */
  -    }
  +    try { if (null != m_ResultSet) m_ResultSet.close(); }
  +    catch(Exception e) { }
  +    try { if (null != m_Statement) m_Statement.close(); }
  +    catch(Exception e) { }
  +    try {
  +      if (null != m_Connection)
  +        m_ConnectionPool.releaseConnection(m_Connection);
  +    } catch(Exception e) { }
  +  }
   
  -    try
  -    {
  -      if (null != m_Statement) m_Statement.close();
  -    }
  -    catch(Exception e)
  -    {
  -      /* Empty */
  -    }
  +  /**
  +   * When an error occurs, the XConnection will call this method
  +   * do that we can deal with the Connection properly
  +   * @return
  +   */
  +  public void closeOnError( )
  +  {
  +    if (DEBUG) System.out.println("close()");
   
  -    try
  -    {
  -      if (null != m_Connection) m_Connection.close();
  -    }
  -    catch(Exception e)
  -    {
  -      /* Empty */
  -    }
  +    try  { if (null != m_ResultSet) m_ResultSet.close();   }
  +    catch(Exception e) { }
  +    try  { if (null != m_Statement) m_Statement.close();
  +    } catch(Exception e) { }
  +    try {
  +      if (null != m_Connection)
  +        m_ConnectionPool.releaseConnectionOnError(m_Connection);
  +    } catch(Exception e) { }
     }
   
   
  +
     /**
      * @return
      */
  @@ -681,7 +779,11 @@
       }
     }
   
  -  protected int _nextsib(int identity)
  +  /**
  +   * @param identity
  +   * @return
  +   */
  +  protected int _nextsib( int identity )
     {
       // If we are asking for the next row and we have not
       // been there yet then let's see if we can get another
  
  
  
  1.4       +119 -2    
xml-xalan/java/src/org/apache/xalan/lib/sql/SQLErrorDocument.java
  
  Index: SQLErrorDocument.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/SQLErrorDocument.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SQLErrorDocument.java     2001/07/30 17:34:51     1.3
  +++ SQLErrorDocument.java     2001/08/01 02:38:30     1.4
  @@ -61,26 +61,143 @@
   package org.apache.xalan.lib.sql;
   
   import org.apache.xml.dtm.DTMManager;
  +import org.apache.xml.dtm.DTM;
   import java.sql.SQLException;
   
   /**
  + *
  + * A base class that will convert an exception into an XML stream
  + * that can be returned in place of the standard result. The XML
  + * format returned is a follows.
  + *
  + * <ext-error>
  + *  <message> The Message for a generic error </message>
  + *  <sql-error>
  + *    <message> SQL Message from the Exception thrown </message>
  + *    <code> SQL Error Code </stack>
  + *  </sql-error>
  + * <ext-error>
  + *
  + */
  +
  +/**
    * The SQL Document is the main controlling class the executesa SQL Query
    */
   public class SQLErrorDocument extends DTMDocument
   {
     /**
  +   */
  +  private static final String S_EXT_ERROR = "ext-error";
  +  /**
  +   */
  +  private static final String S_SQL_ERROR = "sql-error";
  +  /**
      */
  -  public SQLErrorDocument(DTMManager mgr, int ident,  SQLException error )
  +  private static final String S_MESSAGE = "message";
  +  /**
  +   */
  +  private static final String S_CODE = "code";
  +
  +  /**
  +   */
  +  private int m_ErrorExt_TypeID = DTM.NULL;
  +  /**
  +   */
  +  private int m_Message_TypeID = DTM.NULL;
  +  /**
  +   */
  +  private int m_Code_TypeID = DTM.NULL;
  +
  +  /**
  +   */
  +  private int m_SQLError_TypeID = DTM.NULL;
  +
  +  /**
  +   */
  +  private int m_rootID = DTM.NULL;
  +  /**
  +   */
  +  private int m_extErrorID = DTM.NULL;
  +  /**
  +   */
  +  private int m_MainMessageID = DTM.NULL;
  +
  +  /**
  +   * Build up an SQLErrorDocument that includes the basic error information
  +   * along with the Extended SQL Error information.
  +   * @param mgr
  +   * @param ident
  +   * @param error
  +   */
  +  public SQLErrorDocument( DTMManager mgr, int ident, SQLException error )
     {
       super(mgr, ident);
  +
  +    createExpandedNameTable();
  +    buildBasicStructure(error);
  +
  +    int sqlError = addElement(2, m_SQLError_TypeID, m_extErrorID, 
m_MainMessageID);
  +    int element = DTM.NULL;
  +
  +    element = addElementWithData(
  +      new Integer(error.getErrorCode()), 3,
  +      m_Code_TypeID, sqlError, element);
  +
  +    element = addElementWithData(
  +      error.getLocalizedMessage(), 3,
  +      m_Message_TypeID, sqlError, element);
  +
  +//    this.dumpDTM();
     }
   
   
     /**
  +   * Build up an Error Exception with just the Standard Error Information
  +   * @param mgr
  +   * @param ident
  +   * @param error
      */
  -  public SQLErrorDocument(DTMManager mgr, int ident, Exception error )
  +  public SQLErrorDocument( DTMManager mgr, int ident, Exception error )
     {
       super(mgr, ident);
  +    createExpandedNameTable();
  +    buildBasicStructure(error);
  +  }
  +
  +  /**
  +   * Build up the basic structure that is common for each error.
  +   * @param e
  +   * @return
  +   */
  +  private void buildBasicStructure( Exception e )
  +  {
  +    m_rootID = addElement(0, m_Document_TypeID, DTM.NULL, DTM.NULL);
  +    m_extErrorID = addElement(1, m_ErrorExt_TypeID, m_rootID, DTM.NULL);
  +    m_MainMessageID = addElementWithData
  +      (e.getLocalizedMessage(), 2, m_Message_TypeID, m_extErrorID, DTM.NULL);
  +  }
  +
  +  /**
  +   * Populate the Expanded Name Table with the Node that we will use.
  +   * Keep a reference of each of the types for access speed.
  +   * @return
  +   */
  +  protected void createExpandedNameTable( )
  +  {
  +
  +    super.createExpandedNameTable();
  +
  +    m_ErrorExt_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_EXT_ERROR, 
DTM.ELEMENT_NODE);
  +
  +    m_SQLError_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_SQL_ERROR, 
DTM.ELEMENT_NODE);
  +
  +    m_Message_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_MESSAGE, 
DTM.ELEMENT_NODE);
  +
  +    m_Code_TypeID =
  +      m_expandedNameTable.getExpandedTypeID(S_NAMESPACE, S_CODE, 
DTM.ELEMENT_NODE);
     }
   
   }
  
  
  
  1.18      +250 -62   
xml-xalan/java/src/org/apache/xalan/lib/sql/XConnection.java
  
  Index: XConnection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/lib/sql/XConnection.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XConnection.java  2001/07/30 17:34:51     1.17
  +++ XConnection.java  2001/08/01 02:38:30     1.18
  @@ -66,28 +66,24 @@
   import java.sql.Date;
   import java.sql.Timestamp;
   import java.sql.Time;
  -
   import java.util.Properties;
   import java.util.Vector;
   import java.util.StringTokenizer;
  -
   import org.w3c.dom.Element;
   import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Node;
  -
   import java.util.Vector;
   import java.util.Enumeration;
  -
   import java.math.BigDecimal;
  -
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.DTMManager;
   import org.apache.xml.dtm.ref.DTMManagerDefault;
  -
   import org.apache.xpath.XPathContext;
  -
   import org.apache.xalan.extensions.ExpressionContext;
  +import org.w3c.dom.*;
  +import java.sql.*;
  +import java.util.*;
   
   /**
    * An XSLT extension that allows a stylesheet to
  @@ -108,7 +104,7 @@
     /**
      * Flag for DEBUG mode
      */
  -  private static final boolean DEBUG = true;
  +  private static final boolean DEBUG = false;
   
     /**
      * The Current Connection Pool in Use. An XConnection can only
  @@ -122,7 +118,6 @@
      * to be created. Due to the archititure of the Xalan Extensions,
      * there is no notification of when the Extension is being unloaded and
      * as such, there is a good chance that JDBC COnnections are not closed.
  -   *
      * A finalized is provided to try and catch this situation but since
      * support of finalizers is inconsistant across JVM's this may cause
      * a problem. The robustness of the JDBC Driver is also at issue here.
  @@ -159,11 +154,12 @@
      * Allow the SQL Extensions to return null on error. The Error information 
will
      * be stored in a seperate Error Document that can easily be retrived 
using the
      * getError() method.
  -   *
      * %REVIEW% This functionality will probably be buried inside the 
SQLDocument.
      */
     private SQLErrorDocument m_Error = null;
   
  +  /**
  +   */
     private boolean m_IsDefaultPool = false;
   
     /**
  @@ -171,7 +167,6 @@
      * Streaming mode. Streeaming Mode will reduce the memory footprint
      * to a fixed amount but will not let you traverse the tree more than
      * once since the Row data will be reused for every Row in the Query.
  -   *
      */
     private boolean m_IsStreamingEnabled = false;
   
  @@ -186,48 +181,52 @@
     // connect method to receive full error information.
     //
     /**
  +   * @param exprContext
      * @param ConnPoolName
      */
  -  public XConnection(ExpressionContext exprContext, String ConnPoolName )
  +  public XConnection( ExpressionContext exprContext, String ConnPoolName )
     {
       connect(exprContext, ConnPoolName);
     }
   
     /**
  +   * @param exprContext
      * @param driver
      * @param dbURL
      */
  -  public XConnection(ExpressionContext exprContext, String driver, String 
dbURL )
  +  public XConnection( ExpressionContext exprContext, String driver, String 
dbURL )
     {
       connect(exprContext, driver, dbURL);
     }
   
     /**
  +   * @param exprContext
      * @param list
      */
  -  public XConnection(ExpressionContext exprContext, NodeList list )
  +  public XConnection( ExpressionContext exprContext, NodeList list )
     {
       connect(exprContext, list);
     }
   
     /**
  +   * @param exprContext
      * @param driver
      * @param dbURL
      * @param user
      * @param password
      */
  -  public XConnection(ExpressionContext exprContext, String driver, String 
dbURL, String user, String password )
  +  public XConnection( ExpressionContext exprContext, String driver, String 
dbURL, String user, String password )
     {
       connect(exprContext, driver, dbURL, user, password);
     }
   
     /**
  +   * @param exprContext
      * @param driver
      * @param dbURL
      * @param protocolElem
      */
  -  public XConnection(
  -    ExpressionContext exprContext, String driver, String dbURL, Element 
protocolElem )
  +  public XConnection( ExpressionContext exprContext, String driver, String 
dbURL, Element protocolElem )
     {
       connect(exprContext, driver, dbURL, protocolElem);
     }
  @@ -235,10 +234,11 @@
   
     /**
      * Create an XConnection using the name of an existing Connection Pool
  +   * @param exprContext
      * @param ConnPoolName
      * @return
      */
  -  public XConnection connect(ExpressionContext exprContext, String 
ConnPoolName )
  +  public XConnection connect( ExpressionContext exprContext, String 
ConnPoolName )
     {
       try
       {
  @@ -246,11 +246,6 @@
         m_IsDefaultPool = false;
         return this;
       }
  -//    catch(SQLException e)
  -//    {
  -//      m_Error = new SQLErrorDocument(e);
  -//      return null;
  -//    }
       catch (Exception e)
       {
         buildErrorDocument(exprContext, e);
  @@ -261,11 +256,12 @@
   
     /**
      * Create an XConnection object with just a driver and database URL.
  +   * @param exprContext
      * @param driver JDBC driver of the form foo.bar.Driver.
      * @param dbURL database URL of the form jdbc:subprotocol:subname.
      * @return
      */
  -  public XConnection connect(ExpressionContext exprContext, String driver, 
String dbURL )
  +  public XConnection connect( ExpressionContext exprContext, String driver, 
String dbURL )
     {
       try
       {
  @@ -285,10 +281,11 @@
     }
   
     /**
  +   * @param exprContext
      * @param protocolElem
      * @return
      */
  -  public XConnection connect(ExpressionContext exprContext, Element 
protocolElem )
  +  public XConnection connect( ExpressionContext exprContext, Element 
protocolElem )
     {
       try
       {
  @@ -308,10 +305,11 @@
     }
   
     /**
  +   * @param exprContext
      * @param list
      * @return
      */
  -  public XConnection connect(ExpressionContext exprContext, NodeList list )
  +  public XConnection connect( ExpressionContext exprContext, NodeList list )
     {
       try
       {
  @@ -332,15 +330,14 @@
   
     /**
      * Create an XConnection object with user ID and password.
  +   * @param exprContext
      * @param driver JDBC driver of the form foo.bar.Driver.
      * @param dbURL database URL of the form jdbc:subprotocol:subname.
      * @param user user ID.
      * @param password connection password.
      * @return
      */
  -  public XConnection connect(
  -    ExpressionContext exprContext,
  -    String driver, String dbURL, String user, String password )
  +  public XConnection connect( ExpressionContext exprContext, String driver, 
String dbURL, String user, String password )
     {
       try
       {
  @@ -367,15 +364,14 @@
   
     /**
      * Create an XConnection object with a connection protocol
  +   * @param exprContext
      * @param driver JDBC driver of the form foo.bar.Driver.
      * @param dbURL database URL of the form jdbc:subprotocol:subname.
      * @param protocolElem list of string tag/value connection arguments,
      * normally including at least "user" and "password".
      * @return
      */
  -  public XConnection connect(
  -    ExpressionContext exprContext,
  -    String driver, String dbURL, Element protocolElem )
  +  public XConnection connect( ExpressionContext exprContext, String driver, 
String dbURL, Element protocolElem )
     {
       try
       {
  @@ -428,8 +424,11 @@
      * and its value as the elements value.
      * <protocol name="name of value">value</protocol>
      * </DBINFO-TAG>
  +   * @param e
  +   * @return
  +   * @throws SQLException
      */
  -  private void initFromElement( Element e )throws SQLException
  +  private void initFromElement( Element e )throws SQLException 
     {
   
       Properties prop = new Properties();
  @@ -514,8 +513,13 @@
      * Initilize is being called because we did not have an
      * existing Connection Pool, so let's see if we created one
      * already or lets create one ourselves.
  +   * @param driver
  +   * @param dbURL
  +   * @param prop
  +   * @return
  +   * @throws SQLException
      */
  -  private void init( String driver, String dbURL, Properties prop )throws 
SQLException
  +  private void init( String driver, String dbURL, Properties prop )throws 
SQLException 
     {
       if (DEBUG)
         System.out.println("XConnection, Connection Init");
  @@ -567,6 +571,7 @@
   
     /**
      * Execute a query statement by instantiating an
  +   * @param exprContext
      * @param queryString the SQL query.
      * @return XStatement implements NodeIterator.
      * @throws SQLException
  @@ -576,9 +581,15 @@
      * @link org.apache.xalan.lib.sql.RowSet RowSet},
      * a row-set element.
      */
  -//  public DTMAxisIterator query(ExpressionContext exprContext, String 
queryString)
  -  public DTM query(ExpressionContext exprContext, String queryString)
  +  public DTM query( ExpressionContext exprContext, String queryString )
     {
  +    Connection con = null;
  +    Statement stmt = null;
  +    ResultSet rs = null;
  +
  +    DTMManagerDefault mgrDefault = null;
  +    SQLDocument doc = null;
  +
       try
       {
         if (DEBUG) System.out.println("query()");
  @@ -588,19 +599,43 @@
           return null;
         }
   
  -      Connection con = m_ConnectionPool.getConnection();
  -      Statement stmt = con.createStatement();
  -      ResultSet rs = stmt.executeQuery(queryString);
  +      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) { }
  +
  +        // Re throw the error so the process can handle the error
  +        // normally
  +        throw e;
  +      }
   
         if (DEBUG) System.out.println("..creatingSQLDocument");
   
         DTMManager mgr =
           ((XPathContext.XPathExpressionContext)exprContext).getDTMManager();
  -      DTMManagerDefault mgrDefault = (DTMManagerDefault) mgr;
  +      mgrDefault = (DTMManagerDefault) mgr;
         int dtmIdent = mgrDefault.getFirstFreeDTMID();
   
  -      SQLDocument doc =
  -        new SQLDocument(mgr, dtmIdent << 20 , con, stmt, rs, 
m_IsStreamingEnabled);
  +      doc =
  +        new SQLDocument(
  +          mgr, dtmIdent << 20 ,
  +          m_ConnectionPool, con, stmt, rs, m_IsStreamingEnabled);
  +
         if (null != doc)
         {
           if (DEBUG) System.out.println("..returning Document");
  @@ -614,17 +649,27 @@
         }
         else
         {
  -        // Build Error Doc, BAD Result Set
           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;
  @@ -637,6 +682,7 @@
   
     /**
      * Execute a parameterized query statement by instantiating an
  +   * @param exprContext
      * @param queryString the SQL query.
      * @return XStatement implements NodeIterator.
      * @throws SQLException
  @@ -646,14 +692,37 @@
      * @link org.apache.xalan.lib.sql.RowSet RowSet},
      * a row-set element.
      */
  -  public DTM pquery(ExpressionContext exprContext, String queryString )
  +  public DTM pquery( ExpressionContext exprContext, String queryString )
     {
  +    Connection con = null;
  +    PreparedStatement stmt = null;
  +    ResultSet rs = null;
  +
       try
       {
         int indx;
   
  -      Connection con = m_ConnectionPool.getConnection();
  -      PreparedStatement stmt = con.prepareStatement(queryString);
  +      try
  +      {
  +        con = m_ConnectionPool.getConnection();
  +        stmt = con.prepareStatement(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 != stmt) stmt.close(); }
  +        catch(Exception e1) { }
  +        try {
  +          if (null != con) m_ConnectionPool.releaseConnectionOnError(con);
  +        }  catch(Exception e1) {}
  +
  +        // Re throw the error so the process can handle the error
  +        // normally
  +        throw e;
  +      }
   
         if (DEBUG) System.out.println("..building Prepared Statement");
   
  @@ -666,7 +735,28 @@
           indx++;
         }
   
  -      ResultSet rs = stmt.executeQuery();
  +      try
  +      {
  +        rs = stmt.executeQuery();
  +      }
  +      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) { }
  +
  +        // Re throw the error so the process can handle the error
  +        // normally
  +        throw e;
  +      }
   
         if (DEBUG) System.out.println("..creatingSQLDocument");
   
  @@ -676,7 +766,9 @@
         int dtmIdent = mgrDefault.getFirstFreeDTMID();
   
         SQLDocument doc =
  -        new SQLDocument(mgr, dtmIdent << 20 , con, stmt, rs, 
m_IsStreamingEnabled);
  +        new SQLDocument(mgr, dtmIdent << 20 ,
  +        m_ConnectionPool, con, stmt, rs, m_IsStreamingEnabled);
  +
         if (null != doc)
         {
           if (DEBUG) System.out.println("..returning Document");
  @@ -709,6 +801,7 @@
   
     /**
      * Execute a parameterized query statement by instantiating an
  +   * @param exprContext
      * @param queryString the SQL query.
      * @param typeInfo
      * @return XStatement implements NodeIterator.
  @@ -723,8 +816,12 @@
      * the parameter types will be used to overload the current types
      * in the current parameter list.
      */
  -  public DTM pquery(ExpressionContext exprContext, String queryString, 
String typeInfo)
  +  public DTM pquery( ExpressionContext exprContext, String queryString, 
String typeInfo )
     {
  +    Connection con = null;
  +    PreparedStatement stmt = null;
  +    ResultSet rs = null;
  +
       try
       {
         int indx;
  @@ -750,8 +847,29 @@
           indx++;
         }
   
  -      Connection con = m_ConnectionPool.getConnection();
  -      PreparedStatement stmt = con.prepareStatement(queryString);
  +      try
  +      {
  +        con = m_ConnectionPool.getConnection();
  +        stmt = con.prepareStatement(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 != stmt) stmt.close(); }
  +        catch(Exception e1) { }
  +        try {
  +          if (null != con) m_ConnectionPool.releaseConnectionOnError(con);
  +        } catch(Exception e1) { }
  +
  +        // Re throw the error so the process can handle the error
  +        // normally
  +        throw e;
  +      }
  +
  +
   
         if (DEBUG) System.out.println("..building Prepared Statement");
   
  @@ -764,8 +882,30 @@
           indx++;
         }
   
  +
  +      try
  +      {
  +        rs = stmt.executeQuery();
  +      }
  +      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) { /* Empty */ }
  +        try { if (null != stmt) stmt.close(); }
  +        catch(Exception e1) { /* Empty */  }
  +        try {
  +          if (null != con) m_ConnectionPool.releaseConnectionOnError(con);
  +        } catch(Exception e1) { /* Empty */ }
  +
  +        // Re throw the error so the process can handle the error
  +        // normally
  +        throw e;
  +      }
   
  -      ResultSet rs = stmt.executeQuery();
   
         if (DEBUG) System.out.println("..creatingSQLDocument");
   
  @@ -775,7 +915,9 @@
         int dtmIdent = mgrDefault.getFirstFreeDTMID();
   
         SQLDocument doc =
  -        new SQLDocument(mgr, dtmIdent << 20 , con, stmt, rs, 
m_IsStreamingEnabled);
  +        new SQLDocument(mgr, dtmIdent << 20 ,
  +        m_ConnectionPool, con, stmt, rs, m_IsStreamingEnabled);
  +
         if (null != doc)
         {
           if (DEBUG) System.out.println("..returning Document");
  @@ -924,6 +1066,13 @@
       } while ( (n = n.getNextSibling()) != null);
     }
   
  +  /**
  +   * @return
  +   */
  +  public void clearParameters( )
  +  {
  +    m_ParameterList.removeAllElements();
  +  }
   
     /**
      * There is a problem with some JDBC drivers when a Connection
  @@ -974,6 +1123,7 @@
      * memory consumption is greatly reduces so you can have queries
      * of unlimited size but it will not let you traverse the data
      * more than once.
  +   * @return
      */
     public void enableStreamingMode( )
     {
  @@ -989,6 +1139,7 @@
      * memory consumption is greatly reduces so you can have queries
      * of unlimited size but it will not let you traverse the data
      * more than once.
  +   * @return
      */
     public void disableStreamingMode( )
     {
  @@ -1000,9 +1151,21 @@
     }
   
     /**
  +   * Provide access to the last error that occued. This error
  +   * may be over written when the next operation occurs.
  +   * @return
  +   */
  +  public DTM getError( )
  +  {
  +    return m_Error;
  +  }
  +
  +  /**
      * Close the connection to the data source.
  +   * @return
  +   * @throws SQLException
      */
  -  public void close( )throws SQLException
  +  public void close( )throws SQLException 
     {
   
       if (DEBUG)
  @@ -1019,13 +1182,19 @@
         m_OpenSQLDocuments.removeElementAt(0);
       }
   
  +    if (DEBUG)
  +      System.out.println("Exiting XConnection.close");
  +
     }
   
     /**
      * Close the connection to the data source. Only close the connections
      * for a single document.
  +   * @param sqldoc
  +   * @return
  +   * @throws SQLException
      */
  -  public void close(SQLDocument sqldoc)throws SQLException
  +  public void close( SQLDocument sqldoc )throws SQLException 
     {
       if (DEBUG)
         System.out.println("Entering XConnection.close");
  @@ -1045,10 +1214,13 @@
   
     /**
      * Set the parameter for a Prepared Statement
  -   *
  +   * @param pos
  +   * @param stmt
  +   * @param p
  +   * @return
  +   * @throws SQLException
      */
  -  public void setParameter(int pos, PreparedStatement stmt, QueryParameter p)
  -    throws SQLException
  +  public void setParameter( int pos, PreparedStatement stmt, QueryParameter 
p )throws SQLException 
     {
       String type = p.getType();
       if (type.equalsIgnoreCase("string"))
  @@ -1115,7 +1287,12 @@
   
     }
   
  -  private void buildErrorDocument(ExpressionContext exprContext, 
SQLException excp)
  +  /**
  +   * @param exprContext
  +   * @param excp
  +   * @return
  +   */
  +  private void buildErrorDocument( ExpressionContext exprContext, 
SQLException excp )
     {
       try
       {
  @@ -1124,8 +1301,11 @@
         DTMManagerDefault mgrDefault = (DTMManagerDefault) mgr;
         int dtmIdent = mgrDefault.getFirstFreeDTMID();
   
  -      m_Error = new SQLErrorDocument(mgr, dtmIdent, excp);
  +      m_Error = new SQLErrorDocument(mgr, dtmIdent << 20, excp);
   
  +      // Register our document
  +      mgrDefault.addDTM(m_Error, dtmIdent);
  +
       }
       catch(Exception e)
       {
  @@ -1133,7 +1313,12 @@
       }
     }
   
  -  private void buildErrorDocument(ExpressionContext exprContext, Exception 
excp)
  +  /**
  +   * @param exprContext
  +   * @param excp
  +   * @return
  +   */
  +  private void buildErrorDocument( ExpressionContext exprContext, Exception 
excp )
     {
       try
       {
  @@ -1141,8 +1326,11 @@
           ((XPathContext.XPathExpressionContext)exprContext).getDTMManager();
         DTMManagerDefault mgrDefault = (DTMManagerDefault) mgr;
         int dtmIdent = mgrDefault.getFirstFreeDTMID();
  +
  +      m_Error = new SQLErrorDocument(mgr, dtmIdent<<20, excp);
   
  -      m_Error = new SQLErrorDocument(mgr, dtmIdent, excp);
  +      // Register our document
  +      mgrDefault.addDTM(m_Error, dtmIdent);
   
       }
       catch(Exception e)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to