# Package oracle.jdbc.datasource.impl

This package holds data source and connection builder classes that implement the Oracle JDBC extension interfaces in the `oracle.jdbc.datasource` and `oracle.jdbc` packages. The data source implementations in this package will gradually replace the older implementations in packages like `oracle.jdbc.pool` and `oracle.jdbc.replay`. For data source creation using Oracle JDBC driver 20c and higher versions, we strongly recommend that your code use classes in this package, instead of the older ones; for example, use `oracle.jdbc.datasource.impl.OracleDataSource` instead of `oracle.jdbc.pool.OracleDataSource`, or `oracle.jdbc.replay.OracleDataSourceImpl`. This applies to both standalone and application container use cases.

Data source classes in packages `oracle.jdbc.pool` and `oracle.jdbc.replay` continue to function, but will be gradually phased out. For data source creations using Oracle JDBC driver 19c and earlier versions, use these classes.

For most common scenarios, use `oracle.jdbc.datasource.impl.OracleDataSource`. The following example illustrates the use of this data source to create a JDBC connection:

        oracle.jdbc.datasource.OracleDataSource ods =
          new oracle.jdbc.datasource.impl.OracleDataSource();
        ods.setURL("jdbc:oracle:thin:@//dbhost:dbport/dbservice");
        ods.setUser("User");
        ods.setPassword("Passwd");
        ods.setConnectionProperty("connProp1", "value1");
        ods.setConnectionProperty("connProp2", "value2");

        Connection conn = ods.getConnection();

The following example illustrates the use of this data source with the Oracle Universal Connection Pool (UCP):

        oracle.ucp.jdbc.PoolDataSource pds =
          oracle.ucp.jdbc.PoolDataSourceFactory.getPoolDataSource();
        pds.setConnectionFactoryClassName(
          "oracle.jdbc.datasource.impl.OracleDataSource");
        pds.setURL("jdbc:oracle:thin:@//dbhost:dbport/dbservice");
        pds.setUser("User");
        pds.setPassword("Passwd");
        pds.setConnectionProperty("connProp1", "value1");
        pds.setConnectionProperty("connProp2", "value2");

        Connection conn = pds.getConnection();
        ...... // JDBC calls
        conn.close();  // return connection to UCP

The following example illustrates the use of a connection obtained from this data source for Application Continuity protection (note that you must use an AC database service):

        oracle.jdbc.datasource.OracleDataSource ods =
          new oracle.jdbc.datasource.impl.OracleDataSource();
        ods.setURL("jdbc:oracle:thin:@//dbhost:dbport/AC_service");
        ods.setUser("User");
        ods.setPassword("Passwd");
        ods.setConnectionProperty("connProp1", "value1");
        ods.setConnectionProperty("connProp2", "value2");

        oracle.jdbc.OracleConnection conn =
          (oracle.jdbc.OracleConnection) ods.getConnection();
        conn.beginRequest();
        ...... // JDBC calls protected by AC
        conn.endRequest();

The following example illustrates the use of this data source with both UCP and Application Continuity:

        oracle.ucp.jdbc.PoolDataSource pds =
          oracle.ucp.jdbc.PoolDataSourceFactory.getPoolDataSource();
        pds.setConnectionFactoryClassName(
          "oracle.jdbc.datasource.impl.OracleDataSource");
        pds.setURL("jdbc:oracle:thin:@//dbhost:dbport/AC_service");
        pds.setUser("User");
        pds.setPassword("Passwd");
        pds.setConnectionProperty("connProp1", "value1");
        pds.setConnectionProperty("connProp2", "value2");

        Connection conn = pds.getConnection();
        ...... // JDBC calls protected by AC
        conn.close();  // return connection to UCP

`oracle.jdbc.datasource.impl.OracleConnectionPoolDataSource` is for connection pool implementers, and should rarely be used directly.

Since:
  20c
See Also:
  `oracle.jdbc.datasource`, `OracleDataSource`, `OracleConnectionPoolDataSource`

Class Summary
OracleConnectionBuilderImpl: Oracle Implementation class for Connection Builder
OracleConnectionPoolDataSource: A `DataSource` object is a factory for `Connection` objects.
OracleDataSource: A `DataSource` object is a factory for `Connection` objects.
OracleDataSourceFactory: A factory for creating an Oracle datasource.