Class PoolDataSourceImpl

java.lang.Object
oracle.ucp.jdbc.PoolDataSourceImpl
All Implemented Interfaces:
Serializable, Wrapper, Referenceable, ObjectFactory, CommonDataSource, DataSource, Diagnosable, PoolDataSource, UniversalConnectionPoolAdapter
Direct Known Subclasses:
PoolXADataSourceImpl

public class PoolDataSourceImpl extends Object implements PoolDataSource, Serializable, Referenceable, ObjectFactory, UniversalConnectionPoolAdapter

A connection pool-aware data source. This DataSource uses the Universal Connection Pool to get a connection, creating a proxy to that connection, and returning the proxy to the client. When the client calls close on the connection proxy, the underlying physical connection is returned to the pool.

Besides other data source properties, applications must set the connection factory class name. The connection factory class is a class that implements javax.sql.DataSource and does not implement its own connection pooling. The connection factory's getConnection(...) methods should return a physical JDBC connection to the database. For example, "oracle.jdbc.pool.OracleDataSource" is a valid connection factory class name.

Starting in 23.4, new connections are created in the background instead of the user thread. A borrow request may trigger a new connection creation when there is no connection available at the time of the request and if there is room to grow the pool. The borrow request may be satisfied by either a brand new connection created by the background thread or by a connection that was just returned to the pool ??? whichever event happens first. If the connection borrow request can't be satisfied within the Connection Wait Timeout (CWT) then a UniveralConnectionPoolException will be thrown with error code UCP-29.

This behavior is different from 19c or 21c in that:

1. If CWT=0 (or a very small value), a borrow request has a higher chance to throw an exception because it will not give enough time to create a new JDBC connection. A borrow request with CWT=0 can only return a connection if there is one immediately available in the pool.

2. A UCP exception thrown by the connection request will not include the JDBC exception as a cause. To troubleshoot situations where the driver can't connect to the Database, you can implement the ConnectionCreationInformation callback.

A new system property "oracle.ucp.createConnectionInBorrowThread" can be set to "true" to switch back to the old behavior where connections are created in the user thread.

See Also:
  • Field Details

  • Constructor Details

    • PoolDataSourceImpl

      public PoolDataSourceImpl()
  • Method Details

    • startPool

      public void startPool() throws SQLException
      Helper to start pool without keeping metadata connection if initPoolSize is 0.
      Throws:
      SQLException
    • startPool

      public void startPool(oracle.ucp.jdbc.JDBCConnectionRetrievalInfo cri) throws SQLException
      Helper to start pool without keeping metadata connection if initPoolSize is 0.
      Parameters:
      cri - contains username/password for metadata connection creation.
      Throws:
      SQLException
    • startPool

      protected void startPool(oracle.ucp.jdbc.JDBCConnectionRetrievalInfo cri, boolean keepMetadataConn) throws SQLException
      This helper method gets all the pool properties for pool initialization, creates a pool and starts it.
      Parameters:
      cri - contains username/password for metadata connection creation.
      keepMetadataConn - keep metadata connection in the working set even if init pool size is 0 (because the next operation will be "borrow").
      Throws:
      SQLException - if a database-access error occurs.
    • createPoolWithDefaultProperties

      protected void createPoolWithDefaultProperties() throws SQLException
      Throws:
      SQLException
    • createUniversalConnectionPool

      public UniversalConnectionPool createUniversalConnectionPool() throws SQLException
      Creates a Universal Connection Pool instance using this adapter. Pool and connection factory configuration properties should be set on this adapter prior to invoking this method.

      This method should not register the created pool instance with the Universal Connection Pool Manager. The method createConnectionPool on the UniversalConnectionPoolManager is responsible for that.

      This method is intended to be used in association with a UniversalConnectionPoolManager or MBean. Do not directly invoke this method from an instance of this class.

      Specified by:
      createUniversalConnectionPool in interface UniversalConnectionPoolAdapter
      Returns:
      The created Universal Connection Pool instance.
      Throws:
      SQLException - If any error occurs during the process of connection pool creation.
      See Also:
    • reconfigureDataSource

      public void reconfigureDataSource(Properties configuration) throws SQLException
      Reconfigures the data source. This API can be only used to modify existing data source properties. To add a new data source to a running pool instance, use PoolDataSourceFactory's getPoolDataSource(Properties configuration) API instead. Only the following data source properties can be modified using this API: user, password, description, serviceName, pdbRoles.
      Specified by:
      reconfigureDataSource in interface PoolDataSource
      Parameters:
      configuration - the configuration input
      Throws:
      SQLException - If an error occurs while configuring the data source.
    • createUniversalConnectionPoolMBean

      public UniversalConnectionPoolMBean createUniversalConnectionPoolMBean()
      Creates a Universal Connection Pool MBean using this adapter. If a Universal Connection Pool instance is not yet created, this method must first create a pool instance, in which case pool and connection factory configuration properties should be set on this adapter prior to invoking this method.

      This method should not register the created pool MBean with the MBean server. The operation createConnectionPool on the UniversalConnectionPoolManagerMBean is responsible for that.

      Specified by:
      createUniversalConnectionPoolMBean in interface UniversalConnectionPoolAdapter
      Returns:
      The created Universal Connection Pool MBean.
      See Also:
    • getConnection

      public Connection getConnection() throws SQLException
      Attempts to obtain a database connection.
      Specified by:
      getConnection in interface DataSource
      Returns:
      A Connection to the database.
      Throws:
      SQLException - if a database-access error occurs.
    • getConnection

      public Connection getConnection(String username, String password) throws SQLException
      Attempts to obtain a database connection.
      Specified by:
      getConnection in interface DataSource
      Parameters:
      username - The database user on whose behalf the connection is being made.
      password - The user's password.
      Returns:
      A Connection to the database.
      Throws:
      SQLException - if a database-access error occurs.
    • getConnection

      public Connection getConnection(Properties labels) throws SQLException
      Attempts to obtain a database connection with the requested connection labels.
      Specified by:
      getConnection in interface PoolDataSource
      Parameters:
      labels - The requested connection labels.
      Returns:
      A Connection to the database.
      Throws:
      SQLException - if a database-access error occurs.
    • getConnection

      public Connection getConnection(String username, String password, Properties labels) throws SQLException
      Attempts to obtain a database connection with the requested connection labels.
      Specified by:
      getConnection in interface PoolDataSource
      Parameters:
      username - The database user on whose behalf the connection is being made.
      password - The user's password.
      labels - The requested connection labels.
      Returns:
      A Connection to the database.
      Throws:
      SQLException - if a database-access error occurs.
    • getConnection

      protected Connection getConnection(oracle.ucp.jdbc.UCPConnectionBuilderImpl builder) throws SQLException
      Internal method that attempts to obtain a database connection with the parameters set on the builder.
      Parameters:
      builder - the builder object containing the connection properties
      Returns:
      A Connection to the database.
      Throws:
      SQLException - if a database-access error occurs.
    • getLogWriter

      public PrintWriter getLogWriter() throws SQLException
      Specified by:
      getLogWriter in interface CommonDataSource
      Specified by:
      getLogWriter in interface DataSource
      Throws:
      SQLException
    • setLogWriter

      public void setLogWriter(PrintWriter logWriter) throws SQLException
      Specified by:
      setLogWriter in interface CommonDataSource
      Specified by:
      setLogWriter in interface DataSource
      Throws:
      SQLException
    • setLoginTimeout

      public void setLoginTimeout(int seconds) throws SQLException
      Sets the default maximum time in seconds that a driver will wait while attempting to connect to a database once the driver has been identified.
      Specified by:
      setLoginTimeout in interface CommonDataSource
      Specified by:
      setLoginTimeout in interface DataSource
      Parameters:
      seconds - timeout
      Throws:
      SQLException - in case of negative value
    • getLoginTimeout

      public int getLoginTimeout()
      Gets the default maximum time in seconds that a driver will wait while attempting to connect to a database once the driver has been identified.
      Specified by:
      getLoginTimeout in interface CommonDataSource
      Specified by:
      getLoginTimeout in interface DataSource
      Returns:
      timeout in seconds
    • getUser

      public String getUser()
      Description copied from interface: PoolDataSource
      Gets the user name for this data source.
      Specified by:
      getUser in interface PoolDataSource
      Returns:
      userName for this data source.
    • setUser

      public void setUser(String username) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the user name with which connections have to be obtained.
      Specified by:
      setUser in interface PoolDataSource
      Parameters:
      username - Username to be set.
      Throws:
      SQLException - in case of inability to set user.
    • setPassword

      public void setPassword(String password) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the password with which connections have to be obtained.
      Specified by:
      setPassword in interface PoolDataSource
      Parameters:
      password - Password to be set.
      Throws:
      SQLException - in case of inability to set password.
    • getURL

      public String getURL()
      Description copied from interface: PoolDataSource
      Gets the URL for this data source.
      Specified by:
      getURL in interface PoolDataSource
      Returns:
      URL for this data source.
    • setURL

      public void setURL(String url) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the URL that the data source uses to obtain connections to the database.
      Specified by:
      setURL in interface PoolDataSource
      Parameters:
      url - URL to be set.
      Throws:
      SQLException - in case of inability to set URL.
    • setServerName

      public void setServerName(String serverName) throws SQLException
      Sets the database server name.
      Specified by:
      setServerName in interface PoolDataSource
      Parameters:
      serverName - Database server name to be set.
      Throws:
      SQLException - in case of inability to set server name.
    • getServerName

      public String getServerName()
      Gets the database server name.
      Specified by:
      getServerName in interface PoolDataSource
      Returns:
      Database server name.
    • setPortNumber

      public void setPortNumber(int portNumber) throws SQLException
      Sets the database port number.
      Specified by:
      setPortNumber in interface PoolDataSource
      Parameters:
      portNumber - Database port number to be set.
      Throws:
      SQLException - in case of inability to set port number.
    • getPortNumber

      public int getPortNumber()
      Gets the database port number.
      Specified by:
      getPortNumber in interface PoolDataSource
      Returns:
      Database port number.
    • setDatabaseName

      public void setDatabaseName(String databaseName) throws SQLException
      Sets the database name.
      Specified by:
      setDatabaseName in interface PoolDataSource
      Parameters:
      databaseName - Database name to be set.
      Throws:
      SQLException - in case of inability to set db name.
    • getDatabaseName

      public String getDatabaseName()
      Gets the database name.
      Specified by:
      getDatabaseName in interface PoolDataSource
      Returns:
      Database name.
    • setDataSourceName

      public void setDataSourceName(String dataSourceName) throws SQLException
      Sets the data source name.
      Specified by:
      setDataSourceName in interface PoolDataSource
      Parameters:
      dataSourceName - data source name to be set.
      Throws:
      SQLException - in case of inability to set datasource name.
    • getDataSourceName

      public String getDataSourceName()
      Gets the data source name.
      Specified by:
      getDataSourceName in interface PoolDataSource
      Returns:
      data source name.
    • setDescription

      public void setDescription(String dataSourceDescription) throws SQLException
      Sets the data source description.
      Specified by:
      setDescription in interface PoolDataSource
      Parameters:
      dataSourceDescription - data source description to be set.
      Throws:
      SQLException - in case of inability to set description.
    • getDescription

      public String getDescription()
      Gets the data source description.
      Specified by:
      getDescription in interface PoolDataSource
      Returns:
      data source description.
    • setNetworkProtocol

      public void setNetworkProtocol(String networkProtocol) throws SQLException
      Sets the datasource networkProtocol.
      Specified by:
      setNetworkProtocol in interface PoolDataSource
      Parameters:
      networkProtocol - datasource networkProtocol to be set.
      Throws:
      SQLException - in case of inability to set protocol.
    • getNetworkProtocol

      public String getNetworkProtocol()
      Gets the datasource networkProtocol.
      Specified by:
      getNetworkProtocol in interface PoolDataSource
      Returns:
      datasource networkProtocol.
    • setRoleName

      public void setRoleName(String roleName) throws SQLException
      Sets the datasource role name.
      Specified by:
      setRoleName in interface PoolDataSource
      Parameters:
      roleName - datasource role name to be set.
      Throws:
      SQLException - in case of inability to set role name.
    • getRoleName

      public String getRoleName()
      Gets the datasource role name.
      Specified by:
      getRoleName in interface PoolDataSource
      Returns:
      datasource role name.
    • setInitialPoolSize

      public void setInitialPoolSize(int initialPoolSize) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the initial pool size. This is the number of connections that will be created and placed in the pool when the pool is started.

      The range of valid values is 0 to Integer.MAX_VALUE. It is illegal to set this to a value greater than the maximum pool size. Defaults to 0.

      Specified by:
      setInitialPoolSize in interface PoolDataSource
      Parameters:
      initialPoolSize - the initial pool size.
      Throws:
      SQLException - in case of inability to set size.
    • getInitialPoolSize

      public int getInitialPoolSize()
      Description copied from interface: PoolDataSource
      Gets the initial pool size.
      Specified by:
      getInitialPoolSize in interface PoolDataSource
      Returns:
      the initial pool size.
    • setMinPoolSize

      public void setMinPoolSize(int minPoolSize) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the minimum number of connections. If the number of available connections PLUS the number of connections in use IS LESS THAN the minimum then the connection is returned to the pool. Otherwise, the connection is closed.

      The range of valid values is 0 to Integer.MAX_VALUE. It is illegal to set this to a value greater than the maximum pool size. The default is 1 connection.

      Specified by:
      setMinPoolSize in interface PoolDataSource
      Parameters:
      minPoolSize - The minimum number of connections.
      Throws:
      SQLException - in case of inability to set min pool size.
    • getMinPoolSize

      public int getMinPoolSize()
      Description copied from interface: PoolDataSource
      Gets the minimum number of connections that the connection pool will maintain.
      Specified by:
      getMinPoolSize in interface PoolDataSource
      Returns:
      The minimum number of connections.
    • setMinIdle

      public void setMinIdle(int minIdle) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the minimum number of idle connections. If the number of available connections IS LESS THAN the minimum then new connections are created and made available in pool.

      The range of valid values is 0 to Integer.MAX_VALUE. It is illegal to set this to a value greater than the maximum pool size. The default is 0.

      Specified by:
      setMinIdle in interface PoolDataSource
      Parameters:
      minIdle - The minimum number of idle connections.
      Throws:
      SQLException - in case of inability to set min idle.
    • getMinIdle

      public int getMinIdle()
      Description copied from interface: PoolDataSource
      Gets the minimum number of idle connections that the connection pool will maintain.
      Specified by:
      getMinIdle in interface PoolDataSource
      Returns:
      The minimum number of idle connections.
    • setMaxPoolSize

      public void setMaxPoolSize(int maxPoolSize) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the maximum number of connections. The maximum number of connections includes the number of connections that are in use as well as the number of available connections.

      The range of valid values is 1 to Integer.MAX_VALUE. Default value is Integer.MAX_VALUE.

      Specified by:
      setMaxPoolSize in interface PoolDataSource
      Parameters:
      maxPoolSize - The maximum number of connections.
      Throws:
      SQLException - in case of inability to set max pool size.
    • getMaxPoolSize

      public int getMaxPoolSize()
      Description copied from interface: PoolDataSource
      Gets the maximum number of connections that the connection pool will maintain.
      Specified by:
      getMaxPoolSize in interface PoolDataSource
      Returns:
      The maximum number of connections.
    • getMaxConnectionsPerService

      public int getMaxConnectionsPerService()
      Description copied from interface: PoolDataSource
      Gets the maximum number of connections that can be obtained to a particular service, in a shared pool.
      Specified by:
      getMaxConnectionsPerService in interface PoolDataSource
      Returns:
      The maximum number of connections that can be obtained to a particular service.
    • setInactiveConnectionTimeout

      public void setInactiveConnectionTimeout(int inactivityTimeout) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the inactive connection timeout. This timeout determines how long an available connection remains in the connection pool before it is removed from the pool.

      The range of valid values is 0 to Integer.MAX_VALUE. Defaults to 0.

      Setting the value to 0 disables inactive connection timeout processing.

      This property's behaviour is affected by the system property oracle.ucp.timersAffectAllConnections. For more details go to - PoolDataSource.SYSTEM_PROPERTY_TIMERS_AFFECT_ALL_CONNECTIONS.

      Specified by:
      setInactiveConnectionTimeout in interface PoolDataSource
      Parameters:
      inactivityTimeout - The inactive connection timeout in seconds.
      Throws:
      SQLException - in case of inability to set timeout.
    • getInactiveConnectionTimeout

      public int getInactiveConnectionTimeout()
      Description copied from interface: PoolDataSource
      Gets the inactive connection timeout.
      Specified by:
      getInactiveConnectionTimeout in interface PoolDataSource
      Returns:
      The inactivity timeout.
    • setConnectionWaitTimeout

      @Deprecated public void setConnectionWaitTimeout(int waitTimeout) throws SQLException
      Deprecated.
      Description copied from interface: PoolDataSource

      Configures how much time a connection request call may wait before it either successfully returns a connection or throws an exception.

      The wait duration starts from the point when a connection borrow request is submitted to the pool.

      During this time, UCP may either return a connection that's currently available in the pool (ideal scenario) or create a new connection if the pool hasn't reached its maximum size. Otherwise, UCP waits for a connection to be returned to the pool.

      By default, the connection wait timeout is set to 3 seconds.

      Setting the timeout to 0 makes UCP throw an exception immediately if there is no connection available and no room to grow the pool. Note that it still allows UCP to create a new connection if the maximum size hasn't been reached, and that may take some time.

      This method is deprecated. Use PoolDataSource.setConnectionWaitDuration(java.time.Duration) instead.

      Specified by:
      setConnectionWaitTimeout in interface PoolDataSource
      Parameters:
      waitTimeout - The amount of time in seconds for a connection request to wait.
      Throws:
      SQLException - in case it was not possible to set timeout.
    • getConnectionWaitTimeout

      @Deprecated public int getConnectionWaitTimeout()
      Deprecated.
      Description copied from interface: PoolDataSource

      Gets the maximum time (in seconds) that any connection borrow request can wait before it returns to the application.

      This method is deprecated. Use PoolDataSource.getConnectionWaitDuration() instead.

      Specified by:
      getConnectionWaitTimeout in interface PoolDataSource
      Returns:
      The connection wait timeout.
      See Also:
    • setConnectionWaitDuration

      public void setConnectionWaitDuration(Duration duration) throws SQLException
      Description copied from interface: PoolDataSource

      Configures how much time a connection request call may wait before it either successfully returns a connection or throws an exception.

      The wait duration starts from the point when a connection borrow request is submitted to the pool.

      During this time, UCP may either return a connection that's currently available in the pool (ideal scenario) or create a new connection if the pool hasn't reached its maximum size. Otherwise, UCP waits for a connection to be returned to the pool.

      By default, the connection wait timeout is set to 3 seconds.

      Setting the connection wait timeout to Duration.ZERO makes UCP throw an exception immediately if there is no connection available and no room to grow the pool. Note that it still allows UCP to create a new connection if the maximum size hasn't been reached, and that may take some time.

      Specified by:
      setConnectionWaitDuration in interface PoolDataSource
      Parameters:
      duration - The duration for a connection request to wait.
      Throws:
      SQLException - in case it was not possible to set timeout.
    • getConnectionWaitDuration

      public Duration getConnectionWaitDuration()
      Description copied from interface: PoolDataSource

      Gets the maximum time (in seconds) that any connection borrow request can wait before it returns to the application.

      Specified by:
      getConnectionWaitDuration in interface PoolDataSource
      Returns:
      The connection wait duration.
      See Also:
    • setConnectionWaitDurationInMillis

      public void setConnectionWaitDurationInMillis(long duration) throws SQLException
      Throws:
      SQLException
    • getConnectionWaitDurationInMillis

      public long getConnectionWaitDurationInMillis()
    • setTimeToLiveConnectionTimeout

      public void setTimeToLiveConnectionTimeout(int timeToLiveConnectionTimeout) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the maximum time (in seconds) a connection may remain in-use.

      The range of valid values is 0 to Integer.MAX_VALUE. Defaults to 0.

      Setting the value to 0 disables time-to-live connection timeout processing.

      Specified by:
      setTimeToLiveConnectionTimeout in interface PoolDataSource
      Parameters:
      timeToLiveConnectionTimeout - The maximum time (in seconds) a used connection may be active.
      Throws:
      SQLException - in case of inability to set timeout.
    • getTimeToLiveConnectionTimeout

      public int getTimeToLiveConnectionTimeout()
      Description copied from interface: PoolDataSource
      Gets the maximum time (in seconds) a connection may remain in-use. When this timeout expires, the used connection is unconditionally returned to the connection pool. A value of 0 means that the feature is not enabled.
      Specified by:
      getTimeToLiveConnectionTimeout in interface PoolDataSource
      Returns:
      The maximum time (in seconds) a used connection may be active.
    • getAbandonedConnectionTimeout

      public int getAbandonedConnectionTimeout()
      Description copied from interface: PoolDataSource
      Gets the abandoned connection timeout value.
      Specified by:
      getAbandonedConnectionTimeout in interface PoolDataSource
      Returns:
      The abandoned connection timeout.
    • setAbandonedConnectionTimeout

      public void setAbandonedConnectionTimeout(int abandonedConnectionTimeout) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the abandoned connection timeout. This timeout determines how long a borrowed connection can remain unused before it is considered as abandoned and reclaimed by the connection pool.

      The range of valid values is 0 to Integer.MAX_VALUE. Defaults to 0.

      Setting the value to 0 disables abandoned connection timeout.

      Specified by:
      setAbandonedConnectionTimeout in interface PoolDataSource
      Parameters:
      abandonedConnectionTimeout - The value of how long a connection has not been used before it is abandoned (in seconds).
      Throws:
      SQLException - in case of inability to set timeout.
    • setTimeoutCheckInterval

      public void setTimeoutCheckInterval(int timeInterval) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the timeoutCheckInterval (in seconds). This interval specifies how often the timeout properties such as InactiveConnectionTimeout, AbandonedConnectionTimeout, and TimeToLiveConnectionTimeout are enforced.

      The range of valid values is 0 to Integer.MAX_VALUE. Defaults to 30.

      Setting the value to 0 disables all connection timeout processing.

      Specified by:
      setTimeoutCheckInterval in interface PoolDataSource
      Parameters:
      timeInterval - The timeInterval (in seconds) between checks to enforce the timeout properties.
      Throws:
      SQLException - in case of inability to set interval.
    • getTimeoutCheckInterval

      public int getTimeoutCheckInterval()
      Description copied from interface: PoolDataSource
      Gets the timeout check interval (in seconds).
      Specified by:
      getTimeoutCheckInterval in interface PoolDataSource
      Returns:
      timeInterval The timeInterval (in seconds) between checks to enforce the timeout properties.
    • setFastConnectionFailoverEnabled

      public void setFastConnectionFailoverEnabled(boolean failoverEnabled) throws SQLException
      Description copied from interface: PoolDataSource
      Enables Fast Connection Failover (FCF) for the connection pool accessed using this pool-enabled data source. By default, FCF is disabled.
      Specified by:
      setFastConnectionFailoverEnabled in interface PoolDataSource
      Parameters:
      failoverEnabled - true if Fast Connection Failover is enabled; false if not.
      Throws:
      SQLException - in case of inability to set flag.
    • getFastConnectionFailoverEnabled

      public boolean getFastConnectionFailoverEnabled()
      Description copied from interface: PoolDataSource
      Checks if Fast Connection Failover is enabled.
      Specified by:
      getFastConnectionFailoverEnabled in interface PoolDataSource
      Returns:
      true if Fast Connection Failover is enabled; false if not.
    • getConnectionFactoryClassName

      public String getConnectionFactoryClassName()
      Description copied from interface: PoolDataSource
      Gets the Connection Factory class name.
      Specified by:
      getConnectionFactoryClassName in interface PoolDataSource
      Returns:
      Name of the connection factory class specified.
    • setConnectionFactoryClassName

      public void setConnectionFactoryClassName(String factoryClassName) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the Connection Factory class name. This is the connection factory used by the connection pool to create physical connections. Must be set for PoolDataSource to operate.
      Specified by:
      setConnectionFactoryClassName in interface PoolDataSource
      Parameters:
      factoryClassName - Connection factory class name for obtaining physical connections.
      Throws:
      SQLException - in case of inability to set factory class name.
    • setMaxStatements

      public void setMaxStatements(int maxStatements) throws SQLException
      Sets the maximum number of statements that may be pooled or cached on a connection. This is used to enable the statement pooling.
      Specified by:
      setMaxStatements in interface PoolDataSource
      Parameters:
      maxStatements - maximum number of statements to be pooled.
      Throws:
      SQLException - Exception occurred during the process of setting maximum statements that may be pooled on a connection.
    • getMaxStatements

      public int getMaxStatements()
      Gets the maximum number of statements that may be pooled or cached on a Connection.
      Specified by:
      getMaxStatements in interface PoolDataSource
      Returns:
      The maximum number of statements that may be pooled or cached on a Connection.
    • setMaxIdleTime

      public void setMaxIdleTime(int idleTime) throws SQLException
      Sets Idle timeout for available connections in the pool.
      Specified by:
      setMaxIdleTime in interface PoolDataSource
      Parameters:
      idleTime - Idle timeout value in seconds.
      Throws:
      SQLException - in case of inability to set idle time.
    • getMaxIdleTime

      public int getMaxIdleTime()
      Gets Idle timeout value.
      Specified by:
      getMaxIdleTime in interface PoolDataSource
      Returns:
      Idle timeout.
    • setPropertyCycle

      public void setPropertyCycle(int propertyCycle) throws SQLException
      Sets Property cycle in seconds. This is the time interval between checks to enforce connection pool timeout properties.
      Specified by:
      setPropertyCycle in interface PoolDataSource
      Parameters:
      propertyCycle - Time interval in seconds to enforce connection pool timeout properties.
      Throws:
      SQLException - in case of inability to set property cycle.
    • getPropertyCycle

      public int getPropertyCycle()
      Gets Property cycle in seconds.
      Specified by:
      getPropertyCycle in interface PoolDataSource
      Returns:
      PropertyCycle value.
    • setConnectionPoolName

      public void setConnectionPoolName(String connectionPoolName) throws SQLException
      Sets the connection pool name. This property allows the user to specify a String value to name a connection pool instance.
      Specified by:
      setConnectionPoolName in interface PoolDataSource
      Parameters:
      connectionPoolName - Name of connection pool.
      Throws:
      SQLException - in case of inability to set name.
    • getConnectionPoolName

      public String getConnectionPoolName()
      Gets the connection pool name.
      Specified by:
      getConnectionPoolName in interface PoolDataSource
      Returns:
      connectionpoolName.
    • setValidateConnectionOnBorrow

      public void setValidateConnectionOnBorrow(boolean validateConnectionOnBorrow) throws SQLException
      Sets whether or not a connection being borrowed should first be validated.
      Specified by:
      setValidateConnectionOnBorrow in interface PoolDataSource
      Parameters:
      validateConnectionOnBorrow - Whether or not a connection being borrowed should first be validated.
      Throws:
      SQLException - in case of inability to set flag.
      See Also:
    • getValidateConnectionOnBorrow

      public boolean getValidateConnectionOnBorrow()
      Returns whether or not a connection being borrowed should first be validated.
      Specified by:
      getValidateConnectionOnBorrow in interface PoolDataSource
      Returns:
      Whether or not a connection being borrowed should first be validated.
    • setSQLForValidateConnection

      public void setSQLForValidateConnection(String SQLString) throws SQLException
      Sets the value(SQL) for SQLForValidateConnection property. This is used in conjunction with the ValidateConnectionOnBorrow property. The SQL specified should be applicable to back end database and the JDBC driver configured.
      Specified by:
      setSQLForValidateConnection in interface PoolDataSource
      Parameters:
      SQLString - The SQL string used for connection validation.
      Throws:
      SQLException - in case of inability to set SQL string.
    • getSQLForValidateConnection

      public String getSQLForValidateConnection()
      Gets the Value for SQLForValidateConnection property.
      Specified by:
      getSQLForValidateConnection in interface PoolDataSource
      Returns:
      SQLForValidateConnection value.
    • getConnectionHarvestTriggerCount

      public int getConnectionHarvestTriggerCount()
      Gets the number of available connections at which the connection pool's connection harvesting will occur.
      Specified by:
      getConnectionHarvestTriggerCount in interface PoolDataSource
      Returns:
      The number of available connections at which the connection pool's connection harvesting will occur.
    • setConnectionHarvestTriggerCount

      public void setConnectionHarvestTriggerCount(int connectionHarvestTriggerCount) throws SQLException
      Sets the number of available connections at which the connection pool's connection harvesting will occur.
      Specified by:
      setConnectionHarvestTriggerCount in interface PoolDataSource
      Parameters:
      connectionHarvestTriggerCount - The number of available connections at which the connection pool's connection harvesting will occur.
      Throws:
      SQLException - in case of inability to set that count.
    • getConnectionHarvestMaxCount

      public int getConnectionHarvestMaxCount()
      Gets the maximum number of connections that may be harvested when the connection harvesting occurs. Note that it is possible that the number of connections that are harvested may be anywhere from 0 to the connectionHarvestMaxCount.
      Specified by:
      getConnectionHarvestMaxCount in interface PoolDataSource
      Returns:
      The maximum number of connections that may be harvested when the connection harvesting occurs.
    • setConnectionHarvestMaxCount

      public void setConnectionHarvestMaxCount(int connectionHarvestMaxCount) throws SQLException
      Sets the maximum number of connections that may be harvested when the connection harvesting occurs.
      Specified by:
      setConnectionHarvestMaxCount in interface PoolDataSource
      Parameters:
      connectionHarvestMaxCount - the maximum number of connections that may be harvested when the connection harvesting occurs.
      Throws:
      SQLException - in case of inability to set that count.
    • getMaxConnectionReuseTime

      public long getMaxConnectionReuseTime()
      Gets the connection reuse time property.
      Specified by:
      getMaxConnectionReuseTime in interface PoolDataSource
      Returns:
      connection reuse time (in seconds), 0 value means that the feature is disabled.
    • setMaxConnectionReuseTime

      public void setMaxConnectionReuseTime(long maxConnectionReuseTime) throws SQLException
      Gets the connection reuse time property.
      Specified by:
      setMaxConnectionReuseTime in interface PoolDataSource
      Parameters:
      maxConnectionReuseTime - reuse time (in seconds), 0 value means that the feature is disabled.
      Throws:
      SQLException - in case of inability to set reuse time.
    • getMaxConnectionReuseCount

      public int getMaxConnectionReuseCount()
      Gets the connection reuse count property.
      Specified by:
      getMaxConnectionReuseCount in interface PoolDataSource
      Returns:
      connection reuse count, 0 value means that the feature is disabled.
    • setMaxConnectionReuseCount

      public void setMaxConnectionReuseCount(int maxConnectionReuseCount) throws SQLException
      Gets the connection reuse count property.
      Specified by:
      setMaxConnectionReuseCount in interface PoolDataSource
      Parameters:
      maxConnectionReuseCount - reuse count, 0 value means that the feature is disabled.
      Throws:
      SQLException - in case of inability to set reuse time.
    • getAvailableConnectionsCount

      public int getAvailableConnectionsCount()
      Gets the number of available connections in the pool.
      Specified by:
      getAvailableConnectionsCount in interface PoolDataSource
      Returns:
      AvailableConnectionsCount.
    • getBorrowedConnectionsCount

      public int getBorrowedConnectionsCount()
      Gets the number of borrowed connections from the pool.
      Specified by:
      getBorrowedConnectionsCount in interface PoolDataSource
      Returns:
      BorrowedConnectionsCount.
    • getONSConfiguration

      public String getONSConfiguration()
      Returns the ONS configuration string that is used for remote ONS subscription, in the form specified in setONSConfiguration(String). This is used by Fast Connection Failover and Runtime Load Balancing.
      Specified by:
      getONSConfiguration in interface PoolDataSource
      Returns:
      The ONS configuration string used for remote ONS subscription.
    • setONSConfiguration

      public void setONSConfiguration(String onsConfigStr)
      Sets the configuration string used for remote ONS subscription. The parameter string closely resembles the content of the ONS configuration file "ons.config", and contains a list of "name=value" pairs separated by newline character '\n', where name can be one of "nodes", "walletfile", or "walletpassword". The parameter string should at least specify the ONS configuration attribute "nodes", as a list of host:port pairs separated by comma ','. SSL would be used when the "walletfile" attribute is specified as an Oracle wallet file.

      An example ONS configuration string: "nodes=host1:4200,host2:4200\nwalletfile=wfile\nwalletpassword=wpwd"

      This is used primarily by Fast Connection Failover and Runtime Load Balancing.

      Specified by:
      setONSConfiguration in interface PoolDataSource
      Parameters:
      onsConfigStr - The configuration string for remote ONS subscription.
    • registerConnectionLabelingCallback

      public void registerConnectionLabelingCallback(ConnectionLabelingCallback cbk) throws SQLException
      Registers a ConnectionLabelingCallback with the underlying connection pool.
      Specified by:
      registerConnectionLabelingCallback in interface PoolDataSource
      Parameters:
      cbk - The ConnectionLabelingCallback object to be registered.
      Throws:
      SQLException - If there is a callback already registered with the pool.
    • removeConnectionLabelingCallback

      public void removeConnectionLabelingCallback() throws SQLException
      Removes the ConnectionLabelingCallback object registered with the underlying connection pool, if any.
      Specified by:
      removeConnectionLabelingCallback in interface PoolDataSource
      Throws:
      SQLException - If callback removal fails.
    • registerConnectionAffinityCallback

      public void registerConnectionAffinityCallback(ConnectionAffinityCallback cbk) throws SQLException
      Registers a ConnectionAffinityCallback on the connection pool.
      Specified by:
      registerConnectionAffinityCallback in interface PoolDataSource
      Parameters:
      cbk - Affinity Callback object that must be registered.
      Throws:
      SQLException - If callback registration fails.
    • removeConnectionAffinityCallback

      public void removeConnectionAffinityCallback() throws SQLException
      Removes the ConnectionAffinityCallback registered on the connection pool.
      Specified by:
      removeConnectionAffinityCallback in interface PoolDataSource
      Throws:
      SQLException - If callback removal fails.
    • getStatistics

      public JDBCConnectionPoolStatistics getStatistics()
      Gets the statistics of the connection pool.
      Specified by:
      getStatistics in interface PoolDataSource
      Returns:
      The statistics of the connection pool.
    • getServiceName

      public String getServiceName()
      Gets the service name set on this data source
      Specified by:
      getServiceName in interface PoolDataSource
      Returns:
      service name on this data source
    • getConnectionProperties

      public Properties getConnectionProperties()
      Gets the connection properties that are set on this data source. Security sensitive values, like passwords, are omitted from the Properties object returned by this method.
      Specified by:
      getConnectionProperties in interface PoolDataSource
      Returns:
      Connection properties.
    • getConnectionProperty

      public String getConnectionProperty(String propertyName)
      Gets the specified connection property that is set on this data source. Security sensitive values, like passwords, are not returned by this method.
      Specified by:
      getConnectionProperty in interface PoolDataSource
      Parameters:
      propertyName - The name of the specified property.
      Returns:
      The value of the inquired connection property. Null if the property is not set, or is security sensitive.
    • setConnectionProperty

      public void setConnectionProperty(String name, String value) throws SQLException
      Sets a connection property on the connection factory. This is used only for DataSource connection factories that also support connection properties; for example, the oracle.jdbc.pool.OracleDataSource in the Oracle JDBC driver.
      Specified by:
      setConnectionProperty in interface PoolDataSource
      Parameters:
      name - The name of the connection property to be set on the connection factory class.
      value - The value of the connection property to be set on the connection factory class.
      Throws:
      SQLException - If any exception occurred while setting the connection property.
      See Also:
    • setConnectionProperties

      public void setConnectionProperties(Properties connectionProperties) throws SQLException
      Sets the connection properties on the connection factory. This is used only for DataSource connection factories that also support connection properties; for example, the oracle.jdbc.pool.OracleDataSource in the Oracle JDBC driver.
      Specified by:
      setConnectionProperties in interface PoolDataSource
      Parameters:
      connectionProperties - Connection properties to be set on the connection factory class.
      Throws:
      SQLException - If any exception occurred while setting the connection properties.
      See Also:
    • getConnectionFactoryProperties

      public Properties getConnectionFactoryProperties()
      Gets the connection factory properties that are set on this data source.
      Specified by:
      getConnectionFactoryProperties in interface PoolDataSource
      Returns:
      Connection factory properties.
    • getConnectionFactoryProperty

      public String getConnectionFactoryProperty(String propertyName)
      Gets the specified connection factory property that are set on this data source.
      Specified by:
      getConnectionFactoryProperty in interface PoolDataSource
      Parameters:
      propertyName - The name of the specified property.
      Returns:
      The value of the inquired connection factory property. Null if the property is not set.
    • setConnectionFactoryProperty

      public void setConnectionFactoryProperty(String name, String value) throws SQLException
      Sets a connection factory property on the connection factory.

      For connection factories that implement java.sql.Driver, the connection factory property specified here will be assumed as a connection property.

      For DataSource connection factories, the property specified here will be assumed as a DataSource property.

      Specified by:
      setConnectionFactoryProperty in interface PoolDataSource
      Parameters:
      name - The name of the connection factory property to be set on the connection factory class.
      value - The value of the connection factory property to be set on the connection factory class.
      Throws:
      SQLException - If any exception occurred while setting the connection factory property.
      IllegalArgumentException - If the property name or value is invalid.
    • setConnectionFactoryProperties

      public void setConnectionFactoryProperties(Properties factoryProperties) throws SQLException
      Sets the connection factory properties on the connection factory.

      For connection factories that implement java.sql.Driver, the connection factory properties specified here will be assumed as the connection properties.

      For DataSource connection factories, the properties specified here will be assumed as the DataSource properties.

      Specified by:
      setConnectionFactoryProperties in interface PoolDataSource
      Parameters:
      factoryProperties - Connection factory properties to be set on the connection factory class.
      Throws:
      SQLException - If any exception occurred while setting the connection factory properties.
      IllegalArgumentException - If factoryProperties is empty.
    • isSetOnceProperty

      public static boolean isSetOnceProperty(String key)
      Authentication kays to enforce to be set up once per a single pool data source
      Parameters:
      key - to check
      Returns:
      true, if authentication key
    • toBasicType

      public static Object toBasicType(String value, String type)
    • getReference

      public Reference getReference()
      Specified by:
      getReference in interface Referenceable
    • getObjectInstance

      public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable<?,?> env) throws Exception
      Specified by:
      getObjectInstance in interface ObjectFactory
      Throws:
      Exception
    • isWrapperFor

      public boolean isWrapperFor(Class<?> iface) throws SQLException
      Since this class is not a wrapper, just check to see if this implements the requested interface.
      Specified by:
      isWrapperFor in interface Wrapper
      Parameters:
      iface - Requested interface.
      Returns:
      true If this implements the requested interface.
      Throws:
      SQLException - If the argument is not an interface.
      Since:
      JDBC 4.0
    • unwrap

      public <T> T unwrap(Class<T> iface) throws SQLException
      Since this class is not a wrapper, just check to see if this implements the requested interface.
      Specified by:
      unwrap in interface Wrapper
      Parameters:
      iface - Requested interface.
      Returns:
      this If this implements the requested interface.
      Throws:
      SQLException - If this does not implement the arg or the arg is not an interface.
      Since:
      JDBC 4.0
    • registerConnectionInitializationCallback

      public void registerConnectionInitializationCallback(ConnectionInitializationCallback cbk) throws SQLException
      Registers a connection initialization callback.
      Specified by:
      registerConnectionInitializationCallback in interface PoolDataSource
      Parameters:
      cbk - The ConnectionInitializationCallback object to be registered.
      Throws:
      SQLException - If there is a callback already registered with the pool.
    • unregisterConnectionInitializationCallback

      public void unregisterConnectionInitializationCallback() throws SQLException
      Unregisters the connection initialization callback on this pool.
      Specified by:
      unregisterConnectionInitializationCallback in interface PoolDataSource
      Throws:
      SQLException - If callback removal fails.
    • getConnectionInitializationCallback

      public ConnectionInitializationCallback getConnectionInitializationCallback()
      Obtains the registered connection initialization callback, if any.
      Specified by:
      getConnectionInitializationCallback in interface PoolDataSource
      Returns:
      The registered ConnectionInitializationCallback, or null if there is no callback registered.
    • registerConnectionCreationConsumer

      public void registerConnectionCreationConsumer(Consumer<oracle.ucp.ConnectionCreationInformation> consumer)
      Description copied from interface: PoolDataSource
      Registers a connection creation Consumer.
      Specified by:
      registerConnectionCreationConsumer in interface PoolDataSource
      Parameters:
      consumer - The Consumer object to be registered.
    • unregisterConnectionCreationConsumer

      public void unregisterConnectionCreationConsumer()
      Description copied from interface: PoolDataSource
      Unregisters the connection creation Consumer on this pool.
      Specified by:
      unregisterConnectionCreationConsumer in interface PoolDataSource
    • getConnectionCreationConsumer

      public Consumer<oracle.ucp.ConnectionCreationInformation> getConnectionCreationConsumer()
      Description copied from interface: PoolDataSource
      Obtains the registered connection creation Consumer, if any.
      Specified by:
      getConnectionCreationConsumer in interface PoolDataSource
      Returns:
      The registered Consumer, or null if there is no Consumer registered.
    • getConnectionLabelingHighCost

      public int getConnectionLabelingHighCost()
      Description copied from interface: PoolDataSource
      Obtains the cost value which identifies a connection as "high-cost" for connection labeling.
      Specified by:
      getConnectionLabelingHighCost in interface PoolDataSource
      Returns:
      The cost value that identifies a connection as "high-cost" for connection labeling.
      See Also:
    • setConnectionLabelingHighCost

      public void setConnectionLabelingHighCost(int highCost) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the cost value which identifies a connection as "high-cost" for connection labeling. Connection labeling uses the cost(Properties, Properties) method in ConnectionLabelingCallback to find a connection in the pool for a request. When this property is set, connections with a cost value equal to or greater than the property value are considered "high-cost" connections. The default value is Integer.MAX_VALUE.
      Specified by:
      setConnectionLabelingHighCost in interface PoolDataSource
      Parameters:
      highCost - The cost value that identifies a connection as "high-cost" for connection labeling.
      Throws:
      SQLException - If an exception occurs while setting the cost.
    • getConnectionRepurposeThreshold

      public int getConnectionRepurposeThreshold()
      Description copied from interface: PoolDataSource
      Gets the connection repurpose threshold for the pool. This property is used in cases when the connection pool is shared by multiple datasources connecting to the same database but using different services.Only when this threshold is reached the pool will try to repurpose connections between different services before trying to create new connections. This property is applicable only for multi-tenant databases.
      Specified by:
      getConnectionRepurposeThreshold in interface PoolDataSource
      Returns:
      connection repurpose threshold property value currently set.
    • setConnectionRepurposeThreshold

      public void setConnectionRepurposeThreshold(int threshold) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the connection repurpose threshold for the pool. This property is applicable only for multi-tenant databases.
      Specified by:
      setConnectionRepurposeThreshold in interface PoolDataSource
      Parameters:
      threshold - connection repurpose threshold to set.
      Throws:
      SQLException - If any exception occurs while setting the threshold.
      See Also:
    • getHighCostConnectionReuseThreshold

      public int getHighCostConnectionReuseThreshold()
      Description copied from interface: PoolDataSource
      Obtains the high-cost connection reuse threshold property value for connection labeling.
      Specified by:
      getHighCostConnectionReuseThreshold in interface PoolDataSource
      Returns:
      The high-cost connection reuse threshold property value currently set.
      See Also:
    • setHighCostConnectionReuseThreshold

      public void setHighCostConnectionReuseThreshold(int threshold) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the high-cost connection reuse threshold for connection labeling. This property works together with the ConnectionLabelingHighCost property to determine when high-cost connections are reused for connection labeling. This property specifies a threshold of the number of total connections in the pool. If Connection Labeling finds all available connections are high-cost connections (i.e., the lowest cost value exceeds the ConnectionLabelingHighCost value), it checks this threshold to determine whether to reuse those connections. Only when this threshold is reached, Connection Labeling will try to reuse the high-cost connections in the pool to serve a labeled connection request. Otherwise, Connection Labeling picks a low-cost connection, a no-label connection available in the pool, or creates a brand-new physical connection to serve a labeled request. For example, if the property value is set to 10, Connection Labeling reuses high-cost connections when there are no low-cost connections available and the total connections reach 10. Note that any labeled connection with cost Integer.MAX_VALUE will not be reused. This is consistent with connection labeling behavior when this property and ConnectionLabelingHighCost are not set. A Connection Labeling callback must be registered at the same time for this property to take effect. The default value is 0, which is treated the same way as MinPoolSize.
      Specified by:
      setHighCostConnectionReuseThreshold in interface PoolDataSource
      Parameters:
      threshold - The high-cost connection reuse threshold to set.
      Throws:
      SQLException - If any exception occurs while setting the threshold.
    • getPdbRoles

      public Properties getPdbRoles()
      Gets the PDB roles specified for this datasource
      Specified by:
      getPdbRoles in interface PoolDataSource
      Returns:
      roles key values pairs that correspond to the role names and password that are set for this datasource
      See Also:
      • setPdbRoles(java.util.Properties)
    • getSecondsToTrustIdleConnection

      public int getSecondsToTrustIdleConnection()
      Gets the seconds To Trust Idle Connection value. See property description in setSecondsToTrustIdleConnection().
      Specified by:
      getSecondsToTrustIdleConnection in interface PoolDataSource
      Returns:
      Seconds To Trust Idle Connection value.
    • setSecondsToTrustIdleConnection

      public void setSecondsToTrustIdleConnection(int secondsToTrustIdleConnection) throws SQLException
      Sets the time in seconds to trust an idle connection to skip a validation test. It works in conjunction with setValidateConnectionOnBorrow(boolean). When set to any positive value, a connection validation during the checkout is skipped if the connection was successfully used and returned to the pool within the time specified for secondsToTrustIdleConnection. Default value is set to 120 seconds which means that the feature is enabled.
      Specified by:
      setSecondsToTrustIdleConnection in interface PoolDataSource
      Parameters:
      secondsToTrustIdleConnection - The value of how long a connection can be trusted to skip connectionValidationOnBorrow
      Throws:
      SQLException - in case of inability to set these seconds.
    • createConnectionBuilder

      public UCPConnectionBuilder createConnectionBuilder()
      Description copied from interface: PoolDataSource
      Creates a new UCPConnectionBuilder instance.
      Specified by:
      createConnectionBuilder in interface DataSource
      Specified by:
      createConnectionBuilder in interface PoolDataSource
      Returns:
      Connection builder that builds OracleConnection
      See Also:
    • getParentLogger

      public Logger getParentLogger()
      Specified by:
      getParentLogger in interface CommonDataSource
      Returns:
      null
      See Also:
    • getQueryTimeout

      public int getQueryTimeout()
      Gets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.
      Specified by:
      getQueryTimeout in interface PoolDataSource
      Returns:
      The query timeout in seconds
    • setQueryTimeout

      public void setQueryTimeout(int queryTimeout) throws SQLException
      Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds.
      Specified by:
      setQueryTimeout in interface PoolDataSource
      Parameters:
      queryTimeout - in seconds
      Throws:
      SQLException - in case of inability to set that timeout.
    • getMaxConnectionsPerShard

      public int getMaxConnectionsPerShard()
      Gets the currently configured max connections that can be created per shard in a sharded database configuration.
      Specified by:
      getMaxConnectionsPerShard in interface PoolDataSource
      Returns:
      The configured max number of connections that can be created per shard.
    • setMaxConnectionsPerShard

      public void setMaxConnectionsPerShard(int maxConnectionsPerShard) throws SQLException
      Sets the max number of connections that can be created per shard in a sharded database configuration. (Note: This configuration is not compatible with Sharded database configured with Oracle Golden gate)
      Specified by:
      setMaxConnectionsPerShard in interface PoolDataSource
      Parameters:
      maxConnectionsPerShard - The max number of connections that can be created per shard
      Throws:
      SQLException - if there is an any exception while setting this parameter
    • setShardingMode

      public void setShardingMode(boolean shardingMode) throws SQLException
      This API changes the mode of UCP when UCP is using a Sharded Database. By default UCP requires the caller to provide a sharding key for every connection request. When switching off the sharding mode, UCP behaves like a regular connection pool and all the sharding features are disabled so that a caller can request a connection without providing any sharding key.
      Specified by:
      setShardingMode in interface PoolDataSource
      Parameters:
      shardingMode - Mode of UCP when using a Sharded Database.
      Throws:
      SQLException - in case of inability to set sharding mode.
    • getShardingMode

      public boolean getShardingMode()
      Returns the mode of UCP when UCP is using a Sharded Database. By default sharding mode is ON which means UCP requires the caller to provide a sharding key for every connection request.
      Specified by:
      getShardingMode in interface PoolDataSource
      Returns:
      Mode of UCP when using a Sharded Database.
    • setConnectionValidationTimeout

      public void setConnectionValidationTimeout(int connectionValidationTimeout) throws SQLException
      Description copied from interface: PoolDataSource
      This property changes the connection validation timeout which is specified in seconds. Default is 15 seconds. This is the maximum time for connection validation operation. If not completed during this timeout, the connection is treated as invalid.
      Specified by:
      setConnectionValidationTimeout in interface PoolDataSource
      Parameters:
      connectionValidationTimeout - timeout to validate connection
      Throws:
      SQLException - if tiomeout is negative
      See Also:
    • getConnectionValidationTimeout

      public int getConnectionValidationTimeout()
      Description copied from interface: PoolDataSource
      Connection validation timeout getter
      Specified by:
      getConnectionValidationTimeout in interface PoolDataSource
      Returns:
      the current connection validation timaout value in seconds
      See Also:
    • setSSLContext

      public void setSSLContext(SSLContext sslContext)
      Description copied from interface: PoolDataSource
      Specifies a SSLContext to use as a factory for SSLEngine objects that carry out the TLS protocol.

      The SSLContext must be initialized before setting it on PoolDataSource. The certificates specified by that initialization will be used in place of any connection properties that would otherwise have specified certificates, such as oracle.jdbc.OracleConnection#CONNECTION_PROPERTY_KEYSTORE key store and oracle.jdbc.OracleConnection#CONNECTION_PROPERTY_TRUSTSTORE trust store property values.

      Specified by:
      setSSLContext in interface PoolDataSource
      Parameters:
      sslContext - SSLContext instance to be used as an SSLEngine factory.
      See Also:
    • getSSLContext

      protected SSLContext getSSLContext()
      Returns SSL context associated with the datasource.
      Returns:
      SSL context
    • setHostnameResolver

      public void setHostnameResolver(PoolDataSource.HostnameResolver hostnameResolver)
      Description copied from interface: PoolDataSource
      Specifies a PoolDataSource.HostnameResolver to use by the pool
      Specified by:
      setHostnameResolver in interface PoolDataSource
      Parameters:
      hostnameResolver - HostnameResolver instance to be used as a custom DNS name resolver.
      See Also:
    • getHostnameResolver

      public PoolDataSource.HostnameResolver getHostnameResolver()
      Returns the hostname resolver associated with this datasource
      Returns:
      Hostname Resolver
    • isReadOnlyInstanceAllowed

      public boolean isReadOnlyInstanceAllowed()
      Description copied from interface: PoolDataSource
      Returns true if the connection borrow is allowed to a read-only instance, false otherwise. This property is applicable to sharded database only. A shard instance can be in read-only mode for a chunk if chunk move/split operation is in progress.
      Specified by:
      isReadOnlyInstanceAllowed in interface PoolDataSource
      Returns:
      true if the connection borrow is allowed to a read-only instance, false otherwise.
      See Also:
    • setReadOnlyInstanceAllowed

      public void setReadOnlyInstanceAllowed(boolean readOnlyInstanceAllowed) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the read-only instance allowed value on the datasource. This property is applicable to sharded database only. When the property value is set to true, UCP allows connection borrow to read-only instances as well otherwise not. A shard instance goes into read-only mode for a chunk if the chunk move/split operation is in progress on that instance. The default value is false which means by default connection borrow is not allowed to a read-only instance.
      Specified by:
      setReadOnlyInstanceAllowed in interface PoolDataSource
      Parameters:
      readOnlyInstanceAllowed - whether to allow connection borrow to a read-only instance or not
      Throws:
      SQLException - if unable to set property value
      See Also:
    • setTokenSupplier

      public final void setTokenSupplier(Supplier<? extends oracle.jdbc.AccessToken> tokenSupplier) throws SQLException

      Sets a supplier function that generates an access token when creating a connection with this DataSource. The supplier function is invoked each time this DataSource creates a connection. Instances of AccessToken that are output by the supplier must represent a token type that is supported by Oracle Database for client authentication. The supplier must be thread safe.

      It is invalid to configure this DataSource with both a token supplier and with a user name or password. If invocations of setUser(String), setPassword(String), setConnectionProperties(java.util.Properties), or setConnectionProperty(String, String) have configured this DataSource with a user name or password, and an invocation of this method has also configured a token supplier, then a SQLException indicating an invalid configuration is thrown when creating a connection with this datasource.

      Note that AccessToken.createJsonWebTokenCache(Supplier) can be called to create a thread safe Supplier that caches tokens from a user defined Supplier.

      Specified by:
      setTokenSupplier in interface PoolDataSource
      Parameters:
      tokenSupplier - Token supplying function. Not null.
      Throws:
      NullPointerException - If the tokenSupplier is null.
      SQLException - if unable to set property value
    • getDiagnosable

      public Diagnosable getDiagnosable()
      Related diagnosable object
      Specified by:
      getDiagnosable in interface Diagnosable
      Returns:
      diagnosable object for a pool data source
    • isCreateConnectionInBorrowThread

      public boolean isCreateConnectionInBorrowThread()
      Description copied from interface: PoolDataSource
      Returns the connection creation mode: either "true" if connections are created using the borrowing thread, or "false" if connections are created in the background (the default).
      Specified by:
      isCreateConnectionInBorrowThread in interface PoolDataSource
      Returns:
      true, if creating connections in a borrow thread, false otherwise.
      See Also:
    • setCreateConnectionInBorrowThread

      public void setCreateConnectionInBorrowThread(boolean createConnectionInBorrowThread) throws SQLException
      Description copied from interface: PoolDataSource

      Set this flag to true to make UCP use the borrowing thread to create new connections. By default, connections are created in the background. The only reason why you may want to set this to "true" is to make a connection request fail-fast if the driver throws an exception while connecting; otherwise, the background task will keep trying until the connection wait timeout expires.

      If this property is set to false, a pool waits no longer than a designated connection wait duration no matter how long it takes to create a new connection to grow a pool, if no connection is available at this moment. If this property is set to true, then in this backward compatibility mode a pool waits for a connection to be synchronously created in a borrow thread, and the waiting time can take longer than connectionWaitDuration. For connectionWaitDuration please refer to PoolDataSource.setConnectionWaitDuration(java.time.Duration).

      Specified by:
      setCreateConnectionInBorrowThread in interface PoolDataSource
      Parameters:
      createConnectionInBorrowThread - if true, create connections in a borrow thread.
      Throws:
      SQLException - if unable to set property value.
    • isCommitOnConnectionReturn

      public boolean isCommitOnConnectionReturn()
      Description copied from interface: PoolDataSource
      Returns the boolean value for the property that controls the behavior of UCP when a connection is released back to the pool with pending uncommitted changes in an active transaction. By default, UCP will commit the changes (default value is "true"). When setting this property to "false" the changes will be rolled back.
      Specified by:
      isCommitOnConnectionReturn in interface PoolDataSource
      Returns:
      true to commit, false to rollback.
    • setCommitOnConnectionReturn

      public void setCommitOnConnectionReturn(boolean commit) throws SQLException
      Description copied from interface: PoolDataSource
      Sets the boolean value for the property that controls the behavior of UCP when a connection is released back to the pool with pending uncommitted changes in an active transaction. By default, UCP will commit the changes (default value is "true"). When setting this property to "false" the changes will be rolled back.
      Specified by:
      setCommitOnConnectionReturn in interface PoolDataSource
      Parameters:
      commit - 'true' to commit, 'false' to rollback. The default is 'true'.
      Throws:
      SQLException