You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by le...@apache.org on 2002/01/26 17:58:26 UTC

cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/datasource ResourceLimitingJdbcDataSource.java

leif        02/01/26 08:58:26

  Modified:    src/scratchpad/org/apache/avalon/excalibur/datasource
                        ResourceLimitingJdbcDataSource.java
  Log:
  Added the ability to disable the keep-alive feature.
  
  Revision  Changes    Path
  1.3       +18 -10    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java
  
  Index: ResourceLimitingJdbcDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/datasource/ResourceLimitingJdbcDataSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ResourceLimitingJdbcDataSource.java	25 Jan 2002 01:24:27 -0000	1.2
  +++ ResourceLimitingJdbcDataSource.java	26 Jan 2002 16:58:26 -0000	1.3
  @@ -28,7 +28,7 @@
    *     &lt;pool-controller max="<i>10</i>" blocking="<i>true</i>"
    *       timeout="<i>-1</i>" trim-interval="<i>60000</i>"
    *       connection-class="<i>my.overrided.ConnectionClass</i>"&gt;
  - *       &lt;keep-alive&gt;select 1&lt;/keep-alive&gt;
  + *       &lt;keep-alive disable="false"&gt;select 1&lt;/keep-alive&gt;
    *     &lt;/pool-controller&gt;
    *     &lt;driver&gt;<i>com.database.jdbc.JdbcDriver</i>&lt;/driver&gt;
    *     &lt;dburl&gt;<i>jdbc:driver://host/mydb</i>&lt;/dburl&gt;
  @@ -49,7 +49,7 @@
    * </pre>
    *
    * @author <a href="mailto:leif@silveregg.co.jp">Leif Mortenson</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/01/25 01:24:27 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/01/26 16:58:26 $
    * @since 4.1
    */
   public class ResourceLimitingJdbcDataSource 
  @@ -129,8 +129,9 @@
           final String  passwd   = configuration.getChild( "password" ).getValue( null );
           
           final Configuration controller = configuration.getChild( "pool-controller" );
  -        String keepAlive = controller.getChild( "keep-alive" ).getValue(null);
  -
  +        String keepAlive = controller.getChild( "keep-alive" ).getValue( "SELECT 1" );
  +        final boolean disableKeepAlive = controller.getChild( "keep-alive" ).getAttributeAsBoolean( "disable", false );
  +        
           final int     max          = controller.getAttributeAsInteger( "max", 3 );
           final boolean blocking     = controller.getAttributeAsBoolean( "blocking", true );
           final long    timeout      = controller.getAttributeAsLong   ( "timeout", -1 );
  @@ -138,8 +139,8 @@
           final boolean oradb        = controller.getAttributeAsBoolean( "oradb", false );
           
           final boolean autoCommit = configuration.getChild("auto-commit").getValueAsBoolean(true);
  -        final String connectionClass = controller.getAttribute( "connection-class", 
  -            "org.apache.avalon.excalibur.datasource.JdbcConnection" );
  +        // Get the JdbcConnection class.  The factory will resolve one if null.
  +        final String connectionClass = controller.getAttribute( "connection-class", null ); 
   
           final int l_max;
   
  @@ -164,6 +165,7 @@
               }
           }
   
  +        // Validate the max pool size values.
           if( max < 1 )
           {
               if (getLogger().isWarnEnabled())
  @@ -178,6 +180,15 @@
               l_max = max;
           }
   
  +        // If the keepAlive disable attribute was set, then set the keepAlive query to null, disabling it.
  +        if (disableKeepAlive)
  +        {
  +            keepAlive = null;
  +        }
  +        
  +        // If the oradb attribute was set, then override the keepAlive query.
  +        // This will override any specified keepalive value even if disabled.
  +        //  (Deprecated, but keep this for backwards-compatability)
           if (oradb)
           {
               keepAlive = "SELECT 1 FROM DUAL";
  @@ -188,11 +199,8 @@
                                    "keep-alive element instead.");
               }
           }
  -        else
  -        {
  -            keepAlive = "SELECT 1";
  -        }
   
  +        
           final JdbcConnectionFactory factory = new JdbcConnectionFactory
               ( dburl, user, passwd, autoCommit, keepAlive, connectionClass );
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>