pez
pez

Reputation: 1149

What is the difference between OracleDataSourceFactory, OracleConnectionPoolDataSource and OracleDataSource?

What is the difference between OracleDataSourceFactory, OracleConnectionPoolDataSource and OracleDataSource? What are the different situations you would use them in?

Upvotes: 0

Views: 1514

Answers (1)

Jean de Lavarene
Jean de Lavarene

Reputation: 3763

The reason why there is a OracleDataSource and a OracleConnectionPoolDataSource is because the JDBC standard defines two types of connections:

OracleDataSource is a factory of java.sql.Connection objects and that's the datasource that's widely used by applications. On the other hand OracleConnectionPoolDataSource is used for javax.sql.PooledConnection and is used only in connection cache implementations (UCP for example).

You can safely ignore OracleDataSourceFactory which is an artifact to build DataSource objects that Oracle no longer promotes.

With the 19c Oracle JDBC driver, you would instantiate a datasource like this:

oracle.jdbc.datasource.OracleDataSource ds = oracle.jdbc.pool.OracleDataSource();

or, if you're using the replay driver (for Application Continuity):

oracle.jdbc.datasource.OracleDataSource ds = oracle.jdbc.replay.OracleDataSourceImpl();

Upvotes: 2

Related Questions