/**
* Copyright 2010 Wallace Wadge
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jolbox.bonecp;
import java.io.InputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
import java.sql.Connection;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.sql.DataSource;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.google.common.base.Objects;
import com.jolbox.bonecp.hooks.ConnectionHook;
/**
* Configuration class.
*
* @author wallacew
*/
public class BoneCPConfig implements BoneCPConfigMBean, Cloneable, Serializable {
/** Constant. */
private static final String USER = "user";
/** Constant. */
private static final String PASSWORD = "password";
/** Serialization UID. */
private static final long serialVersionUID = 6090570773474131622L;
/** For toString(). */
private static final String CONFIG_TOSTRING = "JDBC URL = %s, Username = %s, partitions = %d, max (per partition) = %d, min (per partition) = %d, helper threads = %d, idle max age = %d min, idle test period = %d min";
/** For toString(). */
private static final String CONFIG_DS_TOSTRING = "JDBC URL = (via datasource bean), Username = (via datasource bean), partitions = %d, max (per partition) = %d, min (per partition) = %d, helper threads = %d, idle max age = %d min, idle test period = %d min";
/** Logger class. */
private static final Logger logger = LoggerFactory.getLogger(BoneCPConfig.class);
/** Min number of connections per partition. */
private int minConnectionsPerPartition;
/** Max number of connections per partition. */
private int maxConnectionsPerPartition;
/** Number of new connections to create in 1 batch. */
private int acquireIncrement = 2;
/** Number of partitions. */
private int partitionCount = 1;
/** DB connection string. */
private String jdbcUrl;
/** User name to use. */
private String username;
/** Password to use. */
private String password;
/** Connections older than this are sent a keep-alive statement. */
private long idleConnectionTestPeriodInSeconds = 240*60;
/** Maximum age of an unused connection before it is closed off. */
private long idleMaxAgeInSeconds = 60*60;
/** SQL statement to use for keep-alive/test of connection. */
private String connectionTestStatement;
/** Min no of prepared statements to cache. */
private int statementsCacheSize = 0;
/** No of statements that can be cached per connection. Deprecated. */
private int statementsCachedPerConnection = 0;
/** Number of release-connection helper threads to create per partition. */
private int releaseHelperThreads = 3;
/** Number of statement release helper threads to create. */
private int statementReleaseHelperThreads = 0;
/** Hook class (external). */
private ConnectionHook connectionHook;
/** Query to send once per connection to the database. */
private String initSQL;
/** If set to true, create a new thread that monitors a connection and displays warnings if application failed to
* close the connection. FOR DEBUG PURPOSES ONLY!
*/
private boolean closeConnectionWatch;
/** If set to true, log SQL statements being executed. */
private boolean logStatementsEnabled;
/** After attempting to acquire a connection and failing, wait for this value before attempting to acquire a new connection again. */
private long acquireRetryDelayInMs=7000;
/** After attempting to acquire a connection and failing, try to connect these many times before giving up. */
private int acquireRetryAttempts=5;
/** If set to true, the connection pool will remain empty until the first connection is obtained. */
private boolean lazyInit;
/** If set to true, stores all activity on this connection to allow for replaying it again. */
private boolean transactionRecoveryEnabled;
/** Connection hook class name. */
private String connectionHookClassName;
/** Classloader to use when loading the JDBC driver. */
private ClassLoader classLoader = this.getClassLoader();
/** Name of the pool for JMX and thread names. */
private String poolName;
/** Set to true to disable JMX. */
private boolean disableJMX;
/** If set, use datasourceBean.getConnection() to obtain a new connection. */
private DataSource datasourceBean;
/** Queries taking longer than this limit to execute are logged. */
private long queryExecuteTimeLimitInMs = 0;
/** Create more connections when we hit x% of our possible number of connections. */
private int poolAvailabilityThreshold = 20;
/** Disable connection tracking. */
private boolean disableConnectionTracking;
/** Used when the alternate way of obtaining a connection is required */
private Properties driverProperties;
/** Time to wait before a call to getConnection() times out and returns an error. */
private long connectionTimeoutInMs = 0;
/** Time in ms to wait for close connection watch thread. */
private long closeConnectionWatchTimeoutInMs = 0;
/** A connection older than maxConnectionAge will be destroyed and purged from the pool. */
private long maxConnectionAgeInSeconds = 0;
/** Config property. */
private String configFile;
/** Queue mode. Values currently understood are FIFO and LIFO. */
private String serviceOrder;
/** If true, keep track of some statistics. */
private boolean statisticsEnabled;
/** The default auto-commit state of created connections. */
private Boolean defaultAutoCommit;
/** The default read-only state of created connections. */
private Boolean defaultReadOnly;
/** The default transaction isolation state of created connections. */
private String defaultTransactionIsolation;
/** The default catalog state of created connections. */
private String defaultCatalog;
/** The parsed transaction isolation value. Default = driver value*/
private int defaultTransactionIsolationValue = -1;
/** If true, stop caring about username/password when obtaining raw connections. */
private boolean externalAuth;
/** Returns the name of the pool for JMX and thread names.
* @return a pool name.
*/
public String getPoolName() {
return this.poolName;
}
/** Sets the name of the pool for JMX and thread names.
* @param poolName to set.
*/
public void setPoolName(String poolName) {
this.poolName = poolName;
}
/** {@inheritDoc}
* @see com.jolbox.bonecp.BoneCPConfigMBean#getMinConnectionsPerPartition()
*/
public int getMinConnectionsPerPartition() {
return this.minConnectionsPerPartition;
}
/**
* Sets the minimum number of connections that will be contained in every partition.
*
* @param minConnectionsPerPartition number of connections
*/
public void setMinConnectionsPerPartition(int minConnectionsPerPartition) {
this.minConnectionsPerPartition = minConnectionsPerPartition;
}
/** {@inheritDoc}
* @see com.jolbox.bonecp.BoneCPConfigMBean#getMaxConnectionsPerPartition()
*/
public int getMaxConnectionsPerPartition() {
return this.maxConnectionsPerPartition;
}
/**
* Sets the maximum number
没有合适的资源?快使用搜索试试~ 我知道了~
基于java的数据库连接池 BoneCP.zip
共43个文件
java:41个
xml:1个
mf:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 192 浏览量
2023-05-28
00:23:54
上传
评论
收藏 112KB ZIP 举报
温馨提示
基于java的数据库连接池 BoneCP.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于java的数据库连接池 BoneCP.zip (43个子文件)
bonecp-default-config.xml 12KB
jsr166y
TransferQueue.java 6KB
LinkedTransferQueue.java 53KB
ThreadLocalRandom.java 7KB
META-INF
MANIFEST.MF 496B
com
jolbox
bonecp
BoneCPConfig.java 63KB
PoolUtil.java 5KB
CloseThreadMonitor.java 3KB
StatementCache.java 7KB
ConnectionHandle.java 42KB
ReplayLog.java 2KB
StatisticsMBean.java 3KB
UsernamePassword.java 2KB
ConnectionTesterThread.java 6KB
proxy
StatementProxy.java 945B
CallableStatementProxy.java 970B
PreparedStatementProxy.java 970B
ConnectionProxy.java 951B
TransactionRecoveryResult.java 1KB
package-info.java 718B
IStatementCache.java 5KB
CallableStatementHandle.java 47KB
CustomThreadFactory.java 3KB
PoolWatchThread.java 4KB
ConnectionPartition.java 12KB
BoundedLinkedTransferQueue.java 3KB
Statistics.java 7KB
ConnectionMaxAgeThread.java 4KB
MemorizeTransactionProxy.java 15KB
BoneCP.java 30KB
BoneCPConfigMBean.java 6KB
BoneCPDataSource.java 8KB
StatementReleaseHelperThread.java 2KB
StatementHandle.java 30KB
hooks
ConnectionState.java 1KB
AbstractConnectionHook.java 4KB
ConnectionHook.java 8KB
AcquireFailConfig.java 4KB
package-info.java 1KB
package-info.java 737B
LIFOQueue.java 3KB
PreparedStatementHandle.java 29KB
ConnectionReleaseHelperThread.java 3KB
共 43 条
- 1
资源评论
易小侠
- 粉丝: 6453
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- top-hat.zip
- 基于matlab实现的图像增强与去噪.rar
- FEproject (1).ipynb
- 基于matlab实现的维纳滤波对图像去噪与最小二乘方滤波对图像去噪的比较.rar
- 基于matlab实现的维也纳大学的LTE链路级仿真平台,实现了LTE两路及仿真的整个个过程.rar
- 基于matlab实现的维也纳大学的LTE上行链路仿真平台 LTE-Link-Level-Uplink-1.0.rar
- morphological-gradient.zip
- 爱立信5G小包优化功能验证.docx
- 基于matlab实现的相移光纤光栅,均匀光栅,啁啾光栅源程序 在均匀光栅中间引入一个相移点,得到反射谱.rar
- 基于matlab实现的协方差矩阵稀疏表示的信源估计程序和论文.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功