⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poolconfig.java

📁 c3p0数据库连接池实现源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Distributed as part of c3p0 v.0.9.1-pre6 * * Copyright (C) 2005 Machinery For Change, Inc. * * Author: Steve Waldman <swaldman@mchange.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1, as  * published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this software; see the file LICENSE.  If not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */package com.mchange.v2.c3p0;import java.util.Properties;import java.io.InputStream;import java.io.IOException;import com.mchange.v1.io.InputStreamUtils;import com.mchange.v2.c3p0.impl.C3P0Defaults;import com.mchange.v2.cfg.MultiPropertiesConfig;import com.mchange.v2.log.MLevel;import com.mchange.v2.log.MLog;import com.mchange.v2.log.MLogger;/** *  <p>Encapsulates all the configuration information required by a c3p0 pooled DataSource.</p> * *  <p>Newly constructed PoolConfig objects are preset with default values, *  which you can define yourself (see below), *  or you can rely on c3p0's built-in defaults. Just create a PoolConfig object, and change only the *  properties you care about. Then pass it to the {@link com.mchange.v2.c3p0.DataSources#pooledDataSource(javax.sql.DataSource, com.mchange.v2.c3p0.PoolConfig)} *  method, and you're off!</p> * *  <p>For those interested in the details, configuration properties can be specified in several ways:</p> *  <ol> *    <li>Any property can be set explicitly by calling the corresponding method on a PoolConfig object.</li> *    <li>Any property will default to a value defined by a System Property, using the property name shown the table below.</li> *    <li>Any property not set in either of the above ways will default to a value found in a user-supplied Java properties file, *        which may be placed in the resource path of *        the ClassLoader that loaded the c3p0 libraries under the name <tt>/c3p0.properties</tt>.</li> *    <li>Any property not set in any of the above ways will be defined according c3p0's built-in defaults.</li> *  </ol> * *  <p><i>Please see c3p0's main documentation for a description of all available parameters.</i></p> * *  @deprecated as of c3p0-0.9.1. To manipulate config programmaticall, please use ComboPooledDataSource * */public final class PoolConfig{    final static MLogger logger;    public final static String INITIAL_POOL_SIZE                    = "c3p0.initialPoolSize";     public final static String MIN_POOL_SIZE                        = "c3p0.minPoolSize";    public final static String MAX_POOL_SIZE                        = "c3p0.maxPoolSize";    public final static String IDLE_CONNECTION_TEST_PERIOD          = "c3p0.idleConnectionTestPeriod";    public final static String MAX_IDLE_TIME                        = "c3p0.maxIdleTime";    public final static String PROPERTY_CYCLE                       = "c3p0.propertyCycle";    public final static String MAX_STATEMENTS                       = "c3p0.maxStatements";    public final static String MAX_STATEMENTS_PER_CONNECTION        = "c3p0.maxStatementsPerConnection";    public final static String CHECKOUT_TIMEOUT                     = "c3p0.checkoutTimeout";    public final static String ACQUIRE_INCREMENT                    = "c3p0.acquireIncrement";    public final static String ACQUIRE_RETRY_ATTEMPTS               = "c3p0.acquireRetryAttempts";    public final static String ACQUIRE_RETRY_DELAY                  = "c3p0.acquireRetryDelay";    public final static String BREAK_AFTER_ACQUIRE_FAILURE          = "c3p0.breakAfterAcquireFailure";    public final static String USES_TRADITIONAL_REFLECTIVE_PROXIES  = "c3p0.usesTraditionalReflectiveProxies";    public final static String TEST_CONNECTION_ON_CHECKOUT          = "c3p0.testConnectionOnCheckout";    public final static String TEST_CONNECTION_ON_CHECKIN           = "c3p0.testConnectionOnCheckin";    public final static String CONNECTION_TESTER_CLASS_NAME         = "c3p0.connectionTesterClassName";    public final static String AUTOMATIC_TEST_TABLE                 = "c3p0.automaticTestTable";    public final static String AUTO_COMMIT_ON_CLOSE                 = "c3p0.autoCommitOnClose";    public final static String FORCE_IGNORE_UNRESOLVED_TRANSACTIONS = "c3p0.forceIgnoreUnresolvedTransactions";    public final static String NUM_HELPER_THREADS                   = "c3p0.numHelperThreads";    public final static String PREFERRED_TEST_QUERY                 = "c3p0.preferredTestQuery";    public final static String FACTORY_CLASS_LOCATION               = "c3p0.factoryClassLocation";        public final static String DEFAULT_CONFIG_RSRC_PATH = "/c3p0.properties";        final static PoolConfig DEFAULTS;    static    {	logger = MLog.getLogger( PoolConfig.class );	Properties rsrcProps = findResourceProperties();	PoolConfig rsrcDefaults = extractConfig( rsrcProps, null );	Properties sysProps;	try	    { sysProps = System.getProperties(); }	catch ( SecurityException e )	    {		if (logger.isLoggable(MLevel.WARNING))		    logger.log(MLevel.WARNING, 			       "Read of system Properties blocked -- ignoring any c3p0 configuration via System properties! " +			       "(But any configuration via a c3p0.properties file is still okay!)", 			       e);		sysProps = new Properties(); //TODO -- an alternative approach to getting c3p0-specific sysprops if allowed	    }	DEFAULTS = extractConfig( sysProps, rsrcDefaults );    }    public static int defaultNumHelperThreads()    { return DEFAULTS.getNumHelperThreads(); }    public static String defaultPreferredTestQuery()    { return DEFAULTS.getPreferredTestQuery(); }    public static String defaultFactoryClassLocation()    { return DEFAULTS.getFactoryClassLocation(); }    public static int defaultMaxStatements()    { return DEFAULTS.getMaxStatements(); }    public static int defaultMaxStatementsPerConnection()    { return DEFAULTS.getMaxStatementsPerConnection(); }    public static int defaultInitialPoolSize()    { return DEFAULTS.getInitialPoolSize(); }    public static int defaultMinPoolSize()    { return DEFAULTS.getMinPoolSize(); }    public static int defaultMaxPoolSize()    { return DEFAULTS.getMaxPoolSize(); }    public static int defaultIdleConnectionTestPeriod()    { return DEFAULTS.getIdleConnectionTestPeriod(); }    public static int defaultMaxIdleTime()    { return DEFAULTS.getMaxIdleTime(); }    public static int defaultPropertyCycle()    { return DEFAULTS.getPropertyCycle(); }    public static int defaultCheckoutTimeout()    { return DEFAULTS.getCheckoutTimeout(); }    public static int defaultAcquireIncrement()    { return DEFAULTS.getAcquireIncrement(); }    public static int defaultAcquireRetryAttempts()    { return DEFAULTS.getAcquireRetryAttempts(); }    public static int defaultAcquireRetryDelay()    { return DEFAULTS.getAcquireRetryDelay(); }    public static boolean defaultBreakAfterAcquireFailure()    { return DEFAULTS.isBreakAfterAcquireFailure(); }    public static String defaultConnectionTesterClassName()    { return DEFAULTS.getConnectionTesterClassName(); }    public static String defaultAutomaticTestTable()    { return DEFAULTS.getAutomaticTestTable(); }    public static boolean defaultTestConnectionOnCheckout()    { return DEFAULTS.isTestConnectionOnCheckout(); }    public static boolean defaultTestConnectionOnCheckin()    { return DEFAULTS.isTestConnectionOnCheckin(); }    public static boolean defaultAutoCommitOnClose()    { return DEFAULTS.isAutoCommitOnClose(); }    public static boolean defaultForceIgnoreUnresolvedTransactions()    { return DEFAULTS.isAutoCommitOnClose(); }    public static boolean defaultUsesTraditionalReflectiveProxies()    { return DEFAULTS.isUsesTraditionalReflectiveProxies(); }    int     maxStatements;    int     maxStatementsPerConnection;    int     initialPoolSize;    int     minPoolSize;    int     maxPoolSize;    int     idleConnectionTestPeriod;    int     maxIdleTime;    int     propertyCycle;    int     checkoutTimeout;    int     acquireIncrement;    int     acquireRetryAttempts;    int     acquireRetryDelay;    boolean breakAfterAcquireFailure;    boolean testConnectionOnCheckout;    boolean testConnectionOnCheckin;    boolean autoCommitOnClose;    boolean forceIgnoreUnresolvedTransactions;    boolean usesTraditionalReflectiveProxies;    String  connectionTesterClassName;    String  automaticTestTable;    int     numHelperThreads;    String  preferredTestQuery;    String  factoryClassLocation;    private PoolConfig( Properties props, boolean init ) throws NumberFormatException    {	if (init)	    extractConfig( this, props, DEFAULTS );    }    public PoolConfig( Properties props ) throws NumberFormatException    { this( props, true ); }    public PoolConfig() throws NumberFormatException    { this( null, true ); }    public int getNumHelperThreads()    { return numHelperThreads; }    public String getPreferredTestQuery()    { return preferredTestQuery; }    public String getFactoryClassLocation()    { return factoryClassLocation; }    public int getMaxStatements()    { return maxStatements; }        public int getMaxStatementsPerConnection()    { return maxStatementsPerConnection; }        public int getInitialPoolSize()    { return initialPoolSize; }        public int getMinPoolSize()    { return minPoolSize; }        public int getMaxPoolSize()    { return maxPoolSize; }        public int getIdleConnectionTestPeriod()    { return idleConnectionTestPeriod; }        public int getMaxIdleTime()    { return maxIdleTime; }        public int getPropertyCycle()    { return propertyCycle; }        public int getAcquireIncrement()    { return acquireIncrement; }        public int getCheckoutTimeout()    { return checkoutTimeout; }        public int getAcquireRetryAttempts()    { return acquireRetryAttempts; }        public int getAcquireRetryDelay()    { return acquireRetryDelay; }        public boolean isBreakAfterAcquireFailure()    { return this.breakAfterAcquireFailure;	}    public boolean isUsesTraditionalReflectiveProxies()    { return this.usesTraditionalReflectiveProxies; }    public String getConnectionTesterClassName()    { return connectionTesterClassName; }        public String getAutomaticTestTable()    { return automaticTestTable; }        /**     * @deprecated use isTestConnectionOnCheckout     */    public boolean getTestConnectionOnCheckout()    { return testConnectionOnCheckout; }    public boolean isTestConnectionOnCheckout()    { return this.getTestConnectionOnCheckout(); }    public boolean isTestConnectionOnCheckin()    { return testConnectionOnCheckin; }    public boolean isAutoCommitOnClose()    { return this.autoCommitOnClose;	}    public boolean isForceIgnoreUnresolvedTransactions()    { return this.forceIgnoreUnresolvedTransactions; }        public void setNumHelperThreads( int numHelperThreads )    { this.numHelperThreads = numHelperThreads;	}    public void setPreferredTestQuery( String preferredTestQuery )    { this.preferredTestQuery = preferredTestQuery; }    public void setFactoryClassLocation( String factoryClassLocation )    { this.factoryClassLocation = factoryClassLocation;	}    public void setMaxStatements( int maxStatements )    { this.maxStatements = maxStatements; }        public void setMaxStatementsPerConnection( int maxStatementsPerConnection )    { this.maxStatementsPerConnection = maxStatementsPerConnection; }        public void setInitialPoolSize( int initialPoolSize )    { this.initialPoolSize = initialPoolSize; }        public void setMinPoolSize( int minPoolSize )    { this.minPoolSize = minPoolSize; }        public void setMaxPoolSize( int maxPoolSize )    { this.maxPoolSize = maxPoolSize; }    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -