Class OracleDataSource

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.io.Serializable, java.sql.Wrapper, java.util.EventListener, javax.naming.Referenceable, javax.sql.CommonDataSource, javax.sql.DataSource, OracleCommonDataSource, OracleDataSource, Diagnosable, oracle.jdbc.internal.Monitor, oracle.jdbc.replay.internal.OracleDataSource, OracleDataSource
    Direct Known Subclasses:
    OracleOCIConnectionPool

    public class OracleDataSource
    extends OracleDataSource

    A DataSource object is a factory for Connection objects. An object that implements the DataSource interface will typically be registered with a JNDI service provider. A JDBC driver that is accessed via the DataSource API does not automatically register itself with the DriverManager.

    This data Source supports Application Continuity (AC) and transparent JDBC operation replay upon a failover. To disable such feature, set "oracle.jdbc.enableACSupport" to false either as a Java system property, or as a connection property on this data source.

    For data source creation using Oracle JDBC driver 21c and higher versions, we strongly recommend that your code use oracle.jdbc.datasource.impl.OracleDataSource, instead of this class, which has become a thin wrapper of the former class and will be gradually phased out.

    For data source creation using Oracle JDBC driver 19c and earlier versions, you can still use this class.

    The following example illustrates the use of this data source to create a JDBC connection:

      
        oracle.jdbc.pool.OracleDataSource ods =
          new oracle.jdbc.pool.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 a connection obtained from this data source for Application Continuity protection:

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

    See Also:
    OracleDataSource, oracle.jdbc.datasource.impl, Serialized Form
    • Constructor Detail

      • OracleDataSource

        public OracleDataSource()
                         throws java.sql.SQLException
        Throws:
        java.sql.SQLException