Posted on 2010-06-03 18:26
itVincent 阅读(623)
评论(0) 编辑 收藏
BoneCP 是一个开源的快速的 JDBC 连接池
有以下特性:
Highly scalable, fast connection pool
Callback (hook interceptor) mechanisms on a change of connection state.
Partitioning capability to increase performance
Allows direct access to a connection
Automatic resizing of pool
Statement caching support
Support for obtaining a connection asynchronously (by returning a Future<Connection>)
Release helper threads to release a connection in an asynchronous fashion for higher performance.
Easy mechanism to execute a custom statement on each newly obtained connection (initSQL).
Support to switch to a new database at runtime without shutting down an application
Ability to replay any failed transaction automatically (for the case where database/network goes down etc)
JMX support
Lazy initialization capable
Automatic validation of connections (keep-alives etc)
Allow obtaining of new connections via a datasource rather than via a Driver
Datasource/Hibernate support capable
Debugging hooks to highlight the exact place where a connection was obtained but not closed
Debugging support to show stack locations of connections that were closed twice.
Custom pool name support.
100% unit test code coverage (over 100 JUnit tests).
Free, open source and written in 100% pure Java with very extensive and complete Javadocs
=============================================================
在maven导入jar:
<dependency>
<groupId>com.jolbox</groupId>
<artifactId>bonecp</artifactId>
<version>0.6.5-rc2</version>
</dependency>
此包没有在官方网站上发布,因此在再加入
<repository>
<releases>
<enabled>true</enabled>
</releases>
<id>bonecp-repo</id>
<name>BoneCP Repository</name>
<url>http://jolbox.com/bonecp/downloads/maven</url>
</repository>
=================================================================
在spring配置数据源:
<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>