Home » commons-dbcp-1.2.2-src » org.apache.commons » dbcp » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   
   18   package org.apache.commons.dbcp;
   19   
   20   /**
   21    * Configuration settings for handling abandoned db connections.
   22    *                                                            
   23    * @author Glenn L. Nielsen           
   24    * @version $Revision: 482015 $ $Date: 2006-12-03 19:22:09 -0700 (Sun, 03 Dec 2006) $
   25    * @deprecated This will be removed in a future version of DBCP.
   26    */
   27   public class AbandonedConfig {
   28   
   29       /**
   30        * Whether or not a connection is considered abandoned and eligible
   31        * for removal if it has been idle longer than the removeAbandonedTimeout
   32        */
   33       private boolean removeAbandoned = false;
   34   
   35       /**
   36        * Flag to remove abandoned connections if they exceed the
   37        * removeAbandonedTimeout.
   38        *
   39        * Set to true or false, default false.
   40        * If set to true a connection is considered abandoned and eligible
   41        * for removal if it has been idle longer than the removeAbandonedTimeout.
   42        * Setting this to true can recover db connections from poorly written    
   43        * applications which fail to close a connection.
   44        *
   45        * @return true if abandoned connections are to be removed
   46        */
   47       public boolean getRemoveAbandoned() {
   48           return (this.removeAbandoned);
   49       }
   50   
   51       /**
   52        * Flag to remove abandoned connections if they exceed the
   53        * removeAbandonedTimeout.
   54        *
   55        * Set to true or false, default false.
   56        * If set to true a connection is considered abandoned and eligible   
   57        * for removal if it has been idle longer than the removeAbandonedTimeout.
   58        * Setting this to true can recover db connections from poorly written
   59        * applications which fail to close a connection.
   60        *
   61        * @param removeAbandoned true means abandoned connections will be
   62        *   removed
   63        */
   64       public void setRemoveAbandoned(boolean removeAbandoned) {
   65           this.removeAbandoned = removeAbandoned;
   66       }
   67   
   68       /**
   69        * Timeout in seconds before an abandoned connection can be removed
   70        */
   71       private int removeAbandonedTimeout = 300;
   72   
   73       /**
   74        * Timeout in seconds before an abandoned connection can be removed.
   75        *
   76        * Defaults to 300 seconds.
   77        *
   78        * @return abandoned timeout in seconds
   79        */
   80       public int getRemoveAbandonedTimeout() {
   81           return (this.removeAbandonedTimeout);
   82       }
   83   
   84       /**
   85        * Timeout in seconds before an abandoned connection can be removed.
   86        *
   87        * Defaults to 300 seconds.
   88        *
   89        * @param removeAbandonedTimeout abandoned timeout in seconds
   90        */
   91       public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
   92           this.removeAbandonedTimeout = removeAbandonedTimeout;
   93       }
   94   
   95       /**
   96        * Determines whether or not to log stack traces for application code
   97        * which abandoned a Statement or Connection.
   98        */
   99       private boolean logAbandoned = false;
  100   
  101       /**
  102        * Flag to log stack traces for application code which abandoned
  103        * a Statement or Connection.
  104        *
  105        * Defaults to false.
  106        * Logging of abandoned Statements and Connections adds overhead
  107        * for every Connection open or new Statement because a stack
  108        * trace has to be generated.
  109        * 
  110        * @return boolean true if stack trace logging is turned on for abandoned
  111        *  Statements or Connections
  112        *
  113        */
  114       public boolean getLogAbandoned() {
  115           return (this.logAbandoned);
  116       }
  117   
  118       /**
  119        * Flag to log stack traces for application code which abandoned
  120        * a Statement or Connection.
  121        *
  122        * Defaults to false.
  123        * Logging of abandoned Statements and Connections adds overhead
  124        * for every Connection open or new Statement because a stack
  125        * trace has to be generated.
  126        * @param logAbandoned true turns on abandoned stack trace logging
  127        *
  128        */
  129       public void setLogAbandoned(boolean logAbandoned) {
  130           this.logAbandoned = logAbandoned;
  131       }
  132   
  133   }

Save This Page
Home » commons-dbcp-1.2.2-src » org.apache.commons » dbcp » [javadoc | source]