BoneCP源码——概述

BoneCP是一个开源的Java数据库连接池,其内部使用了JDK1.5的并发包java.util.concurrent来保证同步,而且采用分段思想,避免单点加锁的竞争(ConcurrentHashMap也是使用这种思想来实现的),具有以下特点(官网):   

  • 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/statements
  • 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/statement 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
  • Support for XML/property configuration
  • Idle connection timeouts / max connection age support
  • 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.
  • Clean organised code. 100% unit test branch code coverage (over 180 JUnit tests).
  • Free, open source and written in 100% pure Java with complete Javadocs.

 官网上提供的跟其它连接池的性能测试对比:

Single Thread
  • 1,000,000 get connection / release connection requests
  • No delay between getting/releasing connection.
  • Pool size range: 20-50.
  • Acquire increment: 5
  • Helper threads: 1
  • Partition count: 1

Multi-Thread
  • 500 threads each attempting 100 get/release connection
  • No delay between getting/releasing connection.
  • Pool size range: 50-200.
  • Acquire increment: 5
  • Helper threads: 5

 

 本次学习基于bonecp-0.7.1.RELEASE版本,主要jar包如下:

com.jolbox.bonecp                  连接池核心包
com.jolbox.bonecp.hooks       支持connection状态改变时的事件通知
com.jolbox.bonecp.proxy        代理java.sql.*下的接口,仅供内部使用
此版本主要依赖的外部包有:

slf4j
guava(google lib)

jsr166y

提供外部支持和测试
com.jolbox.bonecp.provider
com.jolbox.bonecp.spring

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值