In an application server environment, should one prefer javax.sql.DataSource or javax.sql.ConnectionPoolDataSource?

前端 未结 2 2033
执笔经年
执笔经年 2021-02-10 01:55

An existing question expresses something similar, but I want to call out a slightly different nuance here.

The basic question: All application servers give the ability to

2条回答
  •  不思量自难忘°
    2021-02-10 02:33

    Just to shed some light: I'm using Postgres, and the API doc from PGConnectionPoolDataSource is quite clear for me:

    public class PGConnectionPoolDataSource
    extends org.postgresql.ds.jdbc4.AbstractJdbc4ConnectionPoolDataSource
    implements javax.sql.ConnectionPoolDataSource
    

    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.

提交回复
热议问题