Reputation: 255
Some tutorial says use org.postgresql.ds.PGConnectionPoolDataSource
but some says just the org.postgresql.ds.PGSimpleDataSource
... what is the difference between the two?
Upvotes: 1
Views: 562
Reputation: 13857
The difference is that the class org.postgresql.ds.PGConnectionPoolDataSource
implements Connection Pooling, therefore it can provide some performance benefits.
According to the documentation:
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.
See also:
Upvotes: 3