Package oracle.ucp.jdbc
Interface UCPConnectionBuilder
-
- All Superinterfaces:
java.sql.ConnectionBuilder
public interface UCPConnectionBuilder extends java.sql.ConnectionBuilderA builder created from aPoolDataSourceobject, used to get a connection to the database that thePoolDataSourceobject represents. The connection properties that were specified for thePoolDataSourceare used as the default values by theUCPConnectionBuilder.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
UCPConnectionBuilderto get aConnection:PoolDataSource pds = new PoolDataSourceImpl(); OracleShardingKey superShardingKey = pds.createShardingKeyBuilder() .subkey("EASTERN_REGION", JDBCType.VARCHAR) .build(); OracleShardingKey shardingKey = pds.createShardingKeyBuilder() .subkey("PITTSBURGH_BRANCH", JDBCType.VARCHAR) .build(); Connection connection = pds.createConnectionBuilder() .user("rafa") .password("tennis") .shardingKey(shardingKey) .superShardingKey(superShardingKey) .build();
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description java.sql.Connectionbuild()Builds the connection object.default java.util.concurrent.CompletionStage<java.sql.Connection>buildAsyncOracle()Creates a completion stage for a connection.default java.util.concurrent.Flow.Publisher<java.sql.Connection>buildConnectionPublisherOracle()Creates a Flow.Publisher for a connection.UCPConnectionBuilderconnectionWaitDuration(java.time.Duration duration)Set connection wait timeout (injava.time.Duration) for this connection builder particularly.UCPConnectionBuilderconnectionWaitTimeout(int timeout)Deprecated.default UCPConnectionBuilderexecutor(java.util.concurrent.Executor executor)Submits an executor to be used in the asynchronous builder's operations.UCPConnectionBuilderlabels(java.util.Properties labels)Sets the labels attribute on the builderUCPConnectionBuilderpassword(java.lang.String password)Sets the password attribute on the builderUCPConnectionBuilderpdbRoles(java.util.Properties pdbRoles)Sets the PDB roles to be set on the connection from the pool in connection repurposing case for a multitenant database.UCPConnectionBuilderproxyProperties(int proxyType, java.util.Properties proxyProperties)Sets the proxy properties on the builder that is used to create proxy session of the particular type as specified by the parameter proxyTypeUCPConnectionBuilderserviceName(java.lang.String serviceName)Sets the service name attribute on the builderUCPConnectionBuildershardingKey(oracle.jdbc.OracleShardingKey shardingKey)UCPConnectionBuildersuperShardingKey(oracle.jdbc.OracleShardingKey superShardingKey)UCPConnectionBuilderuser(java.lang.String user)Sets the user attribute on the builder
-
-
-
Method Detail
-
user
UCPConnectionBuilder user(java.lang.String user)
Sets the user attribute on the builder- Specified by:
userin interfacejava.sql.ConnectionBuilder- Parameters:
user- the database user on whose behalf the connection is being made- Returns:
- this builder object
-
password
UCPConnectionBuilder password(java.lang.String password)
Sets the password attribute on the builder- Specified by:
passwordin interfacejava.sql.ConnectionBuilder- Parameters:
password- to set- Returns:
- this connection builder object
-
labels
UCPConnectionBuilder labels(java.util.Properties labels)
Sets the labels attribute on the builder- Parameters:
labels- The requested connection labels.- Returns:
- this connection builder object
-
serviceName
UCPConnectionBuilder serviceName(java.lang.String serviceName)
Sets the service name attribute on the builder- Parameters:
serviceName- to retrieve the connection- Returns:
- this connection builder instance
-
proxyProperties
UCPConnectionBuilder proxyProperties(int proxyType, java.util.Properties proxyProperties)
Sets the proxy properties on the builder that is used to create proxy session of the particular type as specified by the parameter proxyType- Parameters:
proxyType- create proxy session of this typeproxyProperties- connection with these proxy properties- Returns:
- this connection builder instance
-
shardingKey
UCPConnectionBuilder shardingKey(oracle.jdbc.OracleShardingKey shardingKey)
- Parameters:
shardingKey- Sharding Key object that needs to be part of connection request- Returns:
- This instance of the connection builder.
-
superShardingKey
UCPConnectionBuilder superShardingKey(oracle.jdbc.OracleShardingKey superShardingKey)
- Parameters:
superShardingKey- Super shardingKey key object that needs to be part of connection request- Returns:
- This instance of the connection builder.
-
pdbRoles
UCPConnectionBuilder pdbRoles(java.util.Properties pdbRoles)
Sets the PDB roles to be set on the connection from the pool in connection repurposing case for a multitenant database.- Parameters:
pdbRoles- PDB roles and their passwords passed in as key value pairs- Returns:
- This instance of the connection builder.
-
build
java.sql.Connection build() throws java.sql.SQLExceptionBuilds the connection object.- Specified by:
buildin interfacejava.sql.ConnectionBuilder- Returns:
- Connection of type S built considering the builder attributes
- Throws:
java.sql.SQLException- if there is a failure in building the connection.
-
buildAsyncOracle
default java.util.concurrent.CompletionStage<java.sql.Connection> buildAsyncOracle() throws java.lang.UnsupportedOperationExceptionCreates a completion stage for a connection. The returned stage will be completed when the pool has an available connection to borrow.- Returns:
- A CompletionStage which completes with a connection borrowed from the pool.
- Throws:
java.lang.UnsupportedOperationException- if this method is not implemented
-
buildConnectionPublisherOracle
default java.util.concurrent.Flow.Publisher<java.sql.Connection> buildConnectionPublisherOracle() throws java.lang.UnsupportedOperationExceptionCreates a Flow.Publisher for a connection. The returned stage will be completed when the pool has an available connection to borrow.- Returns:
- A CompletionStage which completes with a connection borrowed from the pool.
- Throws:
java.lang.UnsupportedOperationException- if this method is not implemented
-
executor
default UCPConnectionBuilder executor(java.util.concurrent.Executor executor) throws java.lang.UnsupportedOperationException
Submits an executor to be used in the asynchronous builder's operations.- Parameters:
executor- - executor to submit (default is ForkJoinPool)- Returns:
- a builder
- Throws:
java.lang.UnsupportedOperationException
-
connectionWaitTimeout
@Deprecated UCPConnectionBuilder connectionWaitTimeout(int timeout)
Deprecated.Set connection wait timeout (in seconds) for this connection builder particularly. If not set, the PoolDataSource's setting will be used.This method is deprecated. Use
connectionWaitDuration(java.time.Duration)instead.- Parameters:
timeout- - connection wait timeout (in seconds)- Returns:
- This instance of the connection builder.
-
connectionWaitDuration
UCPConnectionBuilder connectionWaitDuration(java.time.Duration duration)
Set connection wait timeout (injava.time.Duration) for this connection builder particularly. If not set, the PoolDataSource's setting will be used.- Parameters:
duration- - connection wait timeout (injava.time.Duration).- Returns:
- This instance of the connection builder.
-
-