Difference between BasicDatasource and PoolingDatasource

◇◆丶佛笑我妖孽 提交于 2019-12-20 08:56:42

问题


What is the difference between org.apache.commons.dbcp BasicDatasource and PoolingDataSoure? Do both support pooling of connections? When to use each of them ?


回答1:


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.



来源:https://stackoverflow.com/questions/7496391/difference-between-basicdatasource-and-poolingdatasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!