postgresql - Postgres Glassfish 池化

标签 postgresql glassfish connection-pooling

有些教程说使用 org.postgresql.ds.PGConnectionPoolDataSource 但有些教程说只是 org.postgresql.ds.PGSimpleDataSource...两者之间有什么区别?

最佳答案

不同之处在于类 org.postgresql.ds.PGConnectionPoolDataSource 实现了连接池,因此它可以提供一些性能优势。

根据文档:

Class PGSimpleDataSource

Simple DataSource which does not perform connection pooling. In order to use the DataSource, you must set the property databaseName. The settings for serverName, portNumber, user, and password are optional. Note: these properties are declared in the superclass.

Class PGConnectionPoolDataSource

PostgreSQL implementation of ConnectionPoolDataSource. The app server or middleware vendor should provide a DataSource implementation that takes advantage of this ConnectionPoolDataSource. If not, you can use the PostgreSQL implementation known as PoolingDataSource, but that should only be used if your server or middleware vendor does not provide their own. Why? The server may want to reuse the same Connection across all EJBs requesting a Connection within the same Transaction, or provide other similar advanced features.

另见:

关于postgresql - Postgres Glassfish 池化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21634169/

相关文章:

postgresql - RedShift - 带换行符的 CSV 加载

java - 带有 JDBC 或 Hibernate 的 PostgreSQL,用于使用 CSV 数据的 Web 应用程序

sql - 如果序列未被破坏,则从多行获取总时间间隔

java - 如何在 Glassfish 3.0 嵌入式 API 中激活 SSL(HTTPS)?

java - NoSuchMethodException : getProperties on jar execution

linux - 设置 PL/pgSQL 存储过程的处理器优先级

Java EE 6 + GlassFish v3,有人/企业使用这个组合吗?

java - Tomcat/DBCP 空闲超时 : What if server hangs up?

python - 在 C 中进行连接管理有哪些好方法?

python - 如何获取 pymysql 连接的最后一个 sql errno?