Package oracle.jdbc

Interface OracleConnectionBuilder

  • All Superinterfaces:
    ConnectionBuilder

    public interface OracleConnectionBuilder
    extends ConnectionBuilder
    A builder created from a OracleDataSource object, used to establish a connection to the database that the OracleDataSource object represents. The connection properties that were specified for the OracleDataSource are used as the default values by the OracleConnectionBuilder.

    To use the builder, the corresponding builder method needs to be called for each parameter that needs to be part of the connection request followed by a build() method. The order in which the builder methods are called is not important. However if the same builder attribute is applied more than once, only the most recent value will be considered while building the connection. The builder object can be reused to build more than one connection and the builder attributes will be retained across multiple invocations of the build() method.

    The following example illustrates the use of OracleConnectionBuilder to create a OracleConnection:

      
        OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource();
        OracleShardingKey superShardingKey =
            ods.createShardingKeyBuilder()
               .subkey("EASTERN_REGION", JDBCType.VARCHAR)
               .build();
        OracleShardingKey shardingKey =
            ods.createShardingKeyBuilder()
               .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR)
               .build();
        OracleConnection connection = ods.createConnectionBuilder()
                                         .user("rafa")
                                         .password("tennis")
                                         .shardingKey(shardingKey)
                                         .superShardingKey(superShardingKey)
                                         .build();
      
      
    Since:
    12.2
  • <section role="region">
    • Method Detail

      • shardingKey

        OracleConnectionBuilder shardingKey​(OracleShardingKey shardingKey)
        Parameters:
        shardingKey - Sharding Key object that needs to be part of connection request
        Returns:
        This OracleConnectionBuilder object
      • superShardingKey

        OracleConnectionBuilder superShardingKey​(OracleShardingKey superShardingKey)
        Parameters:
        superShardingKey - Super sharding key object that needs to be part of connection request
        Returns:
        This OracleConnectionBuilder object
      • gssCredential

        OracleConnectionBuilder gssCredential​(GSSCredential credential)
        Provide the GSSCredential used to authenticate the connection.
        Parameters:
        credential - used to authenticate the connection. Not null.
        Returns:
        This OracleConnectionBuilder object
      • sslContext

        OracleConnectionBuilder sslContext​(SSLContext sslContext)
        Specifies a SSLContext to use as a factory for SSLEngine objects that carry out the TLS protocol.

        The SSLContext must be initialized before building the connection. The certificates specified by that initialization will be used in place of any connection properties that would otherwise have specified certificates, such as key store and trust store property values.

        Specifying a null value will clear any non-null value that may have been set previously, causing this builder to behave as if this method had never been called at all.

        Parameters:
        sslContext - An SSLContext to use as an SSLEngine factory.
        Returns:
        This OracleConnectionBuilder object
        Since:
        20
      • executorOracle

        default OracleConnectionBuilder executorOracle​(Executor exec)
        Set the Executor used for asynchronous tasks by this ConnectionBuilder and any Connection objects built by it. The default value is ForkJoinPool.commonPool().
        Parameters:
        exec - an Executor to use for asynchronous tasks. Not null.
        Returns:
        this OracleConnectionBuilder
        Since:
        20
      • buildAsyncOracle

        default CompletionStage<OracleConnection> buildAsyncOracle()
                                                            throws SQLException
        Returns a CompletionStage that completes with a Connection having the same state as if it were built by calling build on this ConnectionBuilder.

        The returned stage is completed exceptionally with a SQLException if a failure occurs when building the Connection.

        Returns:
        a CompletionStage which completes with a Connection built by this ConnectionBuilder
        Throws:
        SQLException
        Since:
        20
      • buildConnectionPublisherOracle

        default Flow.Publisher<OracleConnection> buildConnectionPublisherOracle()
                                                                         throws SQLException
        Returns a Publisher that publishes a single Connection object with the same state as if it were built by calling build on this ConnectionBuilder. The returned Publisher does not support multiple Subscribers.
        Returns:
        a Publisher of a Connection built by this ConnectionBuilder
        Throws:
        SQLException
        Since:
        20
    </section>