问题描述
最近,我从此处下载了PostgreSQL的JDBC驱动程序.由于我使用的是Java 1.7 JVM,因此它写为:
Recently I downloaded the JDBC driver for PostgreSQL from here.Since I'm using Java 1.7 JVM and it's written:
我下载JDBC4.问题是其中不存在PoolingDataSource's
.如果您获得JDBC3,则可以使用org.postgresql.jdbc3.Jdbc3PoolingDataSource
或此处
I download JDBC4. The problem is there exist no PoolingDataSource's
in it.If you get JDBC3 you can use org.postgresql.jdbc3.Jdbc3PoolingDataSource
orothers as is seen here.
在JDBC4中是否存在我不知道的任何池DataSource
,或者应该做什么?我改用?我在JDBC4中找到的唯一内容是 PGPoolingDataSource
但我不是确定是否应该使用它,因为基于他们的Java doc消息:
Is there any pooling DataSource
in JDBC4 that I don't know about, or what shouldI use instead? The only thing I found in JDBC4 is PGPoolingDataSource
but I'm notsure if I'm supposed to use this because based on their Java doc message:
推荐答案
使用org.postgresql.ds.PGPoolingDataSource
这是一个示例: http://jdbc.postgresql.org/documentation/head/ds-ds.html
我已经使用JDBC4驱动程序检查了此示例,并且工作正常.
但是,在此链接的文档中,由于其局限性,他们不鼓励使用postgreSQL池数据源:
Use org.postgresql.ds.PGPoolingDataSource
Here is an example: http://jdbc.postgresql.org/documentation/head/ds-ds.html
I've checked this example using JDBC4 driver and it worked fine.
However in documentation from this link they discourage from using postgreSQL pooling data source because of it's limitations:
他们建议使用DBCP连接池: http://commons.apache.org/proper /commons-dbcp/检查它,它会更好-只需下载库文件,将它们放在classpatch中,然后导入到项目中,上面链接中的文档包含示例如何在代码中使用它的示例.
大多数(所有?)应用程序服务器都实现自己的连接池,如果您使用的是应用程序服务器,这是最佳选择.
例如,Tomcat 7拥有自己的连接池实现,甚至比DBCP更好,请查看文档: http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
They recommend to use DBCP connection pool: http://commons.apache.org/proper/commons-dbcp/check it, it is much better - just download library files, place them in a classpatch and import to the project, documentation from the above link contains examples how to use it in code.
Most (all?) application servers implements their own connection pools, if you are using the application server, it's the best option.
For Example Tomcat 7 has it's own implementation of the connection pool, it's even better than DBCP, check documentation: http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html
这篇关于PostgreSQL JDBC的连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!