public interface UCPConnectionBuilder
PoolDataSource
object, used to get a connection to the database that the PoolDataSource
object represents. The connection properties that were specified for the PoolDataSource
are used as the default values by the UCPConnectionBuilder
.
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 UCPConnectionBuilder
to get a Connection
:
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();
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
build()
Builds the connection object.
|
UCPConnectionBuilder |
labels(java.util.Properties labels)
Sets the labels attribute on the builder
|
UCPConnectionBuilder |
password(java.lang.String password)
Sets the password attribute on the builder
|
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.
|
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
|
UCPConnectionBuilder |
serviceName(java.lang.String serviceName)
Sets the service name attribute on the builder
|
UCPConnectionBuilder |
shardingKey(oracle.jdbc.OracleShardingKey shardingKey) |
UCPConnectionBuilder |
superShardingKey(oracle.jdbc.OracleShardingKey superShardingKey) |
UCPConnectionBuilder |
user(java.lang.String user)
Sets the user attribute on the builder
|
UCPConnectionBuilder user(java.lang.String user)
user
- the database user on whose behalf the connection is being madeUCPConnectionBuilder password(java.lang.String password)
password
-UCPConnectionBuilder labels(java.util.Properties labels)
labels
- The requested connection labels.UCPConnectionBuilder serviceName(java.lang.String serviceName)
serviceName
- to retrieve the connectionUCPConnectionBuilder proxyProperties(int proxyType, java.util.Properties proxyProperties)
proxyType
- create proxy session of this typeproxyProperties
- connection with these proxy propertiesfor valid combinations of the proxy session properties
UCPConnectionBuilder shardingKey(oracle.jdbc.OracleShardingKey shardingKey)
shardingKey
- Sharding Key object that needs to be part of connection requestUCPConnectionBuilder superShardingKey(oracle.jdbc.OracleShardingKey superShardingKey)
superShardingKey
- Super shardingKey key object that needs to be part of connection requestUCPConnectionBuilder pdbRoles(java.util.Properties pdbRoles)
pdbRoles
- PDB roles and their passwords passed in as key value pairsjava.sql.Connection build() throws java.sql.SQLException
java.sql.SQLException
- if there is a failure in building the connection.