开发者

Difference between BasicDatasource and PoolingDatasource

开发者 https://www.devze.com 2023-04-06 03:26 出处:网络
What is the difference between org.apache.commons.dbcp BasicDatasource and PoolingDataSoure? Do both support pooling of connections? When to use 开发者_运维知识库each of them ?BasicDataSource is, as t

What is the difference between org.apache.commons.dbcp BasicDatasource and PoolingDataSoure? Do both support pooling of connections? When to use 开发者_运维知识库each of them ?


BasicDataSource is, as the javadoc says, a one-stop shopping for basic needs. It has all the necessary. It creates internally a PoolableDataSource and an ObjectPool.

PoolingDataSource implements the DataSource interface using a provided ObjectPool. PoolingDatasource take cares of whatever has to do with connections (casting, checking validity, setting properties, etc) and ObjectPool take cares of holding and counting this whatever-type-it-is object.

So I should use BasicDataSource. If you need something special maybe can use PoolingDatasource with another implementation of ObjectPool. But I think it would be a rare case.

0

精彩评论

暂无评论...
验证码 换一张
取 消