Interface OracleConnectionBuilder
-
- All Superinterfaces:
ConnectionBuilder
public interface OracleConnectionBuilder extends ConnectionBuilder
A builder created from aOracleDataSourceobject, used to establish a connection to the database that theOracleDataSourceobject represents. The connection properties that were specified for theOracleDataSourceare used as the default values by theOracleConnectionBuilder.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
OracleConnectionBuilderto create aOracleConnection: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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description OracleConnectionbuild()Builds the connection object.default CompletionStage<OracleConnection>buildAsyncOracle()Returns aCompletionStagethat completes with aConnectionhaving the same state as if it were built by callingbuildon thisConnectionBuilder.default Flow.Publisher<OracleConnection>buildConnectionPublisherOracle()Returns aPublisherthat publishes a singleConnectionobject with the same state as if it were built by callingbuildon thisConnectionBuilder.default OracleConnectionBuilderexecutorOracle(Executor exec)Set theExecutorused for asynchronous tasks by thisConnectionBuilderand anyConnectionobjects built by it.OracleConnectionBuildergssCredential(GSSCredential credential)Provide the GSSCredential used to authenticate the connection.OracleConnectionBuilderpassword(String password)OracleConnectionBuilderreadOnlyInstanceAllowed(boolean readOnlyInstanceAllowed)Sets the read-only instance allowed value on this builder.OracleConnectionBuildershardingKey(ShardingKey shardingKey)OracleConnectionBuildershardingKey(OracleShardingKey shardingKey)OracleConnectionBuildersslContext(SSLContext sslContext)Specifies aSSLContextto use as a factory for SSLEngine objects that carry out the TLS protocol.OracleConnectionBuildersuperShardingKey(ShardingKey superShardingKey)OracleConnectionBuildersuperShardingKey(OracleShardingKey superShardingKey)OracleConnectionBuilderuser(String user)
-
-
-
Method Detail
-
user
OracleConnectionBuilder user(String user)
- Specified by:
userin interfaceConnectionBuilder- Parameters:
user-- Returns:
- This
OracleConnectionBuilderobject
-
password
OracleConnectionBuilder password(String password)
- Specified by:
passwordin interfaceConnectionBuilder- Parameters:
password-- Returns:
- This
OracleConnectionBuilderobject
-
shardingKey
OracleConnectionBuilder shardingKey(OracleShardingKey shardingKey)
- Parameters:
shardingKey- Sharding Key object that needs to be part of connection request- Returns:
- This
OracleConnectionBuilderobject
-
superShardingKey
OracleConnectionBuilder superShardingKey(OracleShardingKey superShardingKey)
- Parameters:
superShardingKey- Super sharding key object that needs to be part of connection request- Returns:
- This
OracleConnectionBuilderobject
-
shardingKey
OracleConnectionBuilder shardingKey(ShardingKey shardingKey)
- Specified by:
shardingKeyin interfaceConnectionBuilder- Parameters:
shardingKey- Sharding Key object that needs to be part of connection request- Returns:
- This
OracleConnectionBuilderobject
-
superShardingKey
OracleConnectionBuilder superShardingKey(ShardingKey superShardingKey)
- Specified by:
superShardingKeyin interfaceConnectionBuilder- Parameters:
superShardingKey- Super sharding key object that needs to be part of connection request- Returns:
- This
OracleConnectionBuilderobject
-
gssCredential
OracleConnectionBuilder gssCredential(GSSCredential credential)
Provide the GSSCredential used to authenticate the connection.- Parameters:
credential- used to authenticate the connection. Not null.- Returns:
- This
OracleConnectionBuilderobject
-
sslContext
OracleConnectionBuilder sslContext(SSLContext sslContext)
Specifies aSSLContextto 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
OracleConnectionBuilderobject - Since:
- 20
-
readOnlyInstanceAllowed
OracleConnectionBuilder readOnlyInstanceAllowed(boolean readOnlyInstanceAllowed)
Sets the read-only instance allowed value on this builder. This property is applicable to sharded database only. When the property value is set to true, the database allows connection creation 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 creation is not allowed to a read-only instance.- Parameters:
readOnlyInstanceAllowed- whether to allow connection creation to a read-only instance or not- Returns:
- This
OracleConnectionBuilderobject
-
executorOracle
default OracleConnectionBuilder executorOracle(Executor exec)
Set the
Executorused for asynchronous tasks by thisConnectionBuilderand anyConnectionobjects built by it. The default value isForkJoinPool.commonPool().Asynchronous tasks will be executed as a
PrivilegedActionwith the sameAccessControlContextas the thread which initiated the asynchronous task.The following API calls initiate asynchronous tasks:
buildConnectionPublisherOracle()OraclePreparedStatement.executeAsyncOracle()OraclePreparedStatement.executeQueryAsyncOracle()OraclePreparedStatement.executeUpdateAsyncOracle()OraclePreparedStatement.executeBatchAsyncOracle()OracleResultSet#publisherOracle()OracleBlob.publisherOracle(long)OracleClob.publisherOracle(long)OracleBfile.publisherOracle(long)OracleConnection.commitAsyncOracle()OracleConnection.rollbackAsyncOracle()OracleConnection.closeAsyncOracle()
- Parameters:
exec- an Executor to use for asynchronous tasks. Not null.- Returns:
- this OracleConnectionBuilder
- Since:
- 20
-
buildAsyncOracle
default CompletionStage<OracleConnection> buildAsyncOracle() throws SQLException
Returns aCompletionStagethat completes with aConnectionhaving the same state as if it were built by callingbuildon thisConnectionBuilder.The returned stage is completed exceptionally with a
SQLExceptionif a failure occurs when building theConnection.- Returns:
- a
CompletionStagewhich completes with aConnectionbuilt by thisConnectionBuilder - Throws:
SQLException- Since:
- 20
-
buildConnectionPublisherOracle
default Flow.Publisher<OracleConnection> buildConnectionPublisherOracle() throws SQLException
Returns aPublisherthat publishes a singleConnectionobject with the same state as if it were built by callingbuildon thisConnectionBuilder. The returnedPublisherdoes not support multipleSubscribers.- Returns:
- a
Publisherof aConnectionbuilt by thisConnectionBuilder - Throws:
SQLException- Since:
- 20
-
build
OracleConnection build() throws SQLException
Builds the connection object.- Specified by:
buildin interfaceConnectionBuilder- Returns:
- New
OracleConnectionthat is created. - Throws:
SQLException
-
-