cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ba...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/sql SQLProcessor.java
Date Wed, 07 Jun 2000 19:45:54 GMT
balld       00/06/07 12:45:53

  Modified:    .        changes.xml
               src/org/apache/cocoon/processor/sql SQLProcessor.java
  Log:
  added connection cache to sql processor
  
  Revision  Changes    Path
  1.82      +4 -1      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- changes.xml	2000/06/07 19:40:40	1.81
  +++ changes.xml	2000/06/07 19:45:47	1.82
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes
  -  $Id: changes.xml,v 1.81 2000/06/07 19:40:40 balld Exp $
  +  $Id: changes.xml,v 1.82 2000/06/07 19:45:47 balld Exp $
   -->
   
   <changes title="History of Changes">
  @@ -16,6 +16,9 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="DB" type="fix" due-to="Peter Seiderer" due-to-email="Peter.Seiderer@ciselant.de">
  +   Added connection cache to sql processor
  +  </action>
     <action dev="DB" type="fix" due-to="Jeremy Quinn" due-to-email="jeremy@media.demon.co.uk">
      Disabled "created by cocoon" comment for HTTP HEAD requests.
     </action>
  
  
  
  1.13      +20 -5     xml-cocoon/src/org/apache/cocoon/processor/sql/SQLProcessor.java
  
  Index: SQLProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/sql/SQLProcessor.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SQLProcessor.java	2000/05/12 17:27:45	1.12
  +++ SQLProcessor.java	2000/06/07 19:45:50	1.13
  @@ -62,7 +62,7 @@
    * A processor that performs SQL database queries.
    *
    * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
  - * @version $Revision: 1.12 $ $Date: 2000/05/12 17:27:45 $
  + * @version $Revision: 1.13 $ $Date: 2000/06/07 19:45:50 $
    */
   
   public class SQLProcessor extends AbstractActor implements Processor, Status {
  @@ -98,6 +98,8 @@
        */
       public Document process(Document document, Dictionary parameters) throws Exception
{
           HttpServletRequest request = (HttpServletRequest)parameters.get("request");
  +        Hashtable connections = new Hashtable();
  +        Connection conn = null;
           try {
               ConnectionDefs cdefs = new ConnectionDefs(document);
               NodeList query_nodes = document.getElementsByTagName("query");
  @@ -136,13 +138,28 @@
                           }
                       }
                   }
  -                Connection conn = cdefs.getConnection(query_props.getProperty("connection"));
  +
  +                String conn_name = query_props.getProperty("connection");
  +                if (connections.containsKey(conn_name)) {
  +                    conn = (Connection) connections.get(conn_name);
  +                } else {     
  +                    conn = (Connection) cdefs.getConnection(conn_name);
  +                    connections.put(conn_name, conn);
  +                }
  +                
                   processQuery(document,parameters,query_element,query_props,conn);
               }
           } catch (Exception e) {
               e.printStackTrace();
           }
   
  +        Enumeration conn_list = connections.elements();
  +        while(conn_list.hasMoreElements()) {
  +            Connection c = (Connection) conn_list.nextElement();
  +            c.close();
  +        }
  +        connections.clear();
  +
           return document;
       }
   
  @@ -302,9 +319,7 @@
   			if (!auto_commit) {
               	conn.rollback();
   			}
  -        } finally {
  -          conn.close();
  -        }
  +        } 
       }
   
       /**
  
  
  

Mime
View raw message