gpt4 book ai didi

java - Spring DriverManagerDataSource vs apache BasicDataSource

转载 作者:IT老高 更新时间:2023-10-28 13:50:57 25 4
gpt4 key购买 nike

Spring DriverManagerDataSource 和 apache BasicDataSource 有什么区别?哪一个更可取,在什么情况下?

谢谢。

最佳答案

根据 Spring documentation

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).

另请阅读 Controlling database connections

使用 Spring 的 JDBC 层时,您可以从 JNDI 获取数据源,或者使用第三方提供的连接池实现来配置自己的数据源。流行的实现是 Apache Jakarta Commons DBCP 和 C3P0。 Spring 发行版中的实现仅用于测试目的,不提供池化。

关于java - Spring DriverManagerDataSource vs apache BasicDataSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17945137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com