java jdbc 链接pg_使用PostgreSQL JDBC连接池

使用org.postgresql.ds.PGPoolingDataSource

这是一个例子:

http://jdbc.postgresql.org/documentation/head/ds-ds.html

我已经使用JDBC4驱动程序检查了这个例子,它工作正常.

然而在这个链接的文档中,由于它的局限性,他们不鼓励使用postgreSQL池数据源:

The pooling data-source implementation provided here is not the most feature-rich in the world. Among other things, connections are never closed until the pool itself is closed; there is no way to shrink the pool. As well, connections requested for users other than the default configured user are not pooled. Its error handling sometimes cannot remove a broken connection from the pool. In general it is not recommended to use the PostgreSQL˘ provided connection pool. Check your application server or check out the excellent jakarta commons DBCP project.

他们建议使用DBCP连接池:http://commons.apache.org/proper/commons-dbcp/

检查一下,它更好 – 只需下载库文件,将它们放在一个类中并导入到项目中,从上述链接的文档中包含如何在代码中使用的示例.

大多数(所有?)应用服务器实现自己的连接池,如果您正在使用应用程序服务器,这是最好的选择.

对于示例,Tomcat 7具有自己的连接池的实现,比DBCP更好,检查文档:http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值