数据库连接池

本文深入探讨了Spring框架中DriverManagerDataSource类的使用,解释了其并非真正的数据库连接池,而是作为简化连接池实现的替代方案。文章详细说明了配置数据库连接池的三种方式,并对比了它们之间的差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天看到项目中的数据库连接池用的是org.springframework.jdbc.datasource.DriverManagerDataSource,对这个类并不是很熟悉,google后发现它并不是一个真正的数据库连接池。

Spring文档是这么描述它的:


This class is not an actual connection pool; it does not actually pool Connections. It just serves as simple replacement for a full-blown connection pool, implementing the same standard interface, but creating new Connections on every call.

If you need a "real" connection pool outside of a J2EE container, consider Apache's Jakarta Commons DBCP or C3P0. Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full connection pool beans, supporting the same basic properties as this class plus specific settings (such as minimal/maximal pool size etc).


所以我们有三种方式来配置数据库连接池。

1,基于j2ee容器的jndi连接池

2,c3p0

3,dbcp







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值