300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > java jdbc 链接pg_使用PostgreSQL JDBC连接池

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

时间:2018-11-06 18:11:53

相关推荐

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

使用org.postgresql.ds.PGPoolingDataSource

这是一个例子:

/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连接池:/proper/commons-dbcp/

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

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

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

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。