Interface OracleCommonDataSource
-
- All Superinterfaces:
javax.sql.CommonDataSource
- All Known Subinterfaces:
OracleConnectionPoolDataSource,OracleConnectionPoolDataSource,OracleDataSource,OracleDataSource,OracleXADataSource,OracleXADataSource
- All Known Implementing Classes:
OracleConnectionPoolDataSource,OracleConnectionPoolDataSource,OracleConnectionPoolDataSourceImpl,OracleDataSource,OracleDataSource,OracleDataSourceImpl,OracleOCIConnectionPool,OracleXADataSource,OracleXADataSource,OracleXADataSourceImpl
public interface OracleCommonDataSource extends javax.sql.CommonDataSourceInterface that defines the methods which are common betweenOracleDataSource,OracleXADataSourceandOracleConnectionPoolDataSourceand defines the Oracle extensions to the standard JDBC interfaceCommonDataSource.- Since:
- 12.2
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default OracleShardingKeyBuildercreateShardingKeyBuilder()Creates a newOracleShardingKeyBuilderinstance.java.util.PropertiesgetConnectionProperties()Gets the connection properties that are set on this data source object.java.lang.StringgetConnectionProperty(java.lang.String propertyName)Gets the specified connection property that is set on this data source.java.lang.StringgetDatabaseName()Gets the name of the database set on this DataSource instance.java.lang.StringgetDataSourceName()Gets the datasource name for this instance if set.java.lang.StringgetDescription()Get the Description of this data source.booleangetExplicitCachingEnabled()Returns the current value of the explicitCachingEnabled property.booleangetImplicitCachingEnabled()getImplicitCachingEnabled Returns the current value of the implicitCachingEnabled property.intgetMaxStatements()Returns the current value of the maxStatements property.java.lang.StringgetNetworkProtocol()Gets the network protocol set on the datasource.intgetPortNumber()Gets the port number on which server is listening for requests.java.lang.StringgetRoleName()Gets the data source role name.java.lang.StringgetServerName()Gets the name of the server on which database is running.java.lang.StringgetURL()Gets the URL for this datasource.java.lang.StringgetUser()Gets the user name for this datasource.voidsetConnectionProperties(java.util.Properties value)Sets the Connection Properties for the datasourcevoidsetConnectionProperty(java.lang.String name, java.lang.String value)Sets a connection property on the data source.voidsetDatabaseName(java.lang.String dbname)Sets the name of a particular database on a server.voidsetDataSourceName(java.lang.String dsname)Sets the datasource name.voidsetDescription(java.lang.String des)Sets the Description for this data source instance.voidsetExplicitCachingEnabled(boolean cache)Sets the value of the explicitCachingEnabled property, which enables or disables the explicit cache.voidsetHostnameResolver(OracleHostnameResolver hostnameResolver)Sets a custom hostname resolver implementingOracleHostnameResolverused to provide a custom DNS name resolution strategy to locate the database host.voidsetImplicitCachingEnabled(boolean cache)Sets the value of the implicitCachingEnabled property, which enables or disables the implicit statement cache.voidsetMaxStatements(int max)Specifies the value of the maxStatements property.voidsetNetworkProtocol(java.lang.String np)Sets the network protocol for the connections.voidsetPassword(java.lang.String pd)Sets the password with which connections have to be obtained.voidsetPortNumber(int pn)Sets the port number where a server is listening for requests.voidsetRoleName(java.lang.String roleName)Sets the data source role name.voidsetServerName(java.lang.String sn)Sets the name of the Server on which database is running.voidsetSingleShardTransactionSupport(boolean allow)Sets single shard transaction support in auto commit OFF mode.voidsetSSLContext(javax.net.ssl.SSLContext sslContext)Specifies aSSLContextto use as a factory for SSLEngine objects that carry out the TLS protocol.voidsetTokenSupplier(java.util.function.Supplier<? extends AccessToken> tokenSupplier)Sets a supplier function that generates an access token when creating a connection with thisDataSource.voidsetURL(java.lang.String url)Sets the URL from which connections have to be obtained.voidsetUser(java.lang.String userName)Set the user name with which connections have to be obtained.
-
-
-
Method Detail
-
createShardingKeyBuilder
default OracleShardingKeyBuilder createShardingKeyBuilder() throws java.sql.SQLException
Creates a newOracleShardingKeyBuilderinstance.- Specified by:
createShardingKeyBuilderin interfacejavax.sql.CommonDataSource- Returns:
- The ShardingKeyBuilder instance that was created
- Throws:
java.sql.SQLException- if an error occurs creating the builder- See Also:
OracleShardingKeyBuilder
-
setDataSourceName
void setDataSourceName(java.lang.String dsname) throws java.sql.SQLExceptionSets the datasource name.- Parameters:
dsname- DataSource Name to be set.- Throws:
java.sql.SQLException
-
getDataSourceName
java.lang.String getDataSourceName()
Gets the datasource name for this instance if set. Returns null if not set.- Returns:
- DaraSource name
-
getDatabaseName
java.lang.String getDatabaseName()
Gets the name of the database set on this DataSource instance.- Returns:
- database name set on this instance or null if not set.
-
setDatabaseName
void setDatabaseName(java.lang.String dbname) throws java.sql.SQLExceptionSets the name of a particular database on a server. In Oracle's jargon this is called SID (System Identifier).If URL is set, this property will be ignored.
- Parameters:
dsname- database name to be set.- Throws:
java.sql.SQLException
-
setServerName
void setServerName(java.lang.String sn) throws java.sql.SQLExceptionSets the name of the Server on which database is running. If URL is set, this property will be ignored.- Parameters:
sn- server/host name to be set.- Throws:
java.sql.SQLException
-
getServerName
java.lang.String getServerName()
Gets the name of the server on which database is running.- Returns:
- server name set on this instance or null if not set.
-
setURL
void setURL(java.lang.String url) throws java.sql.SQLExceptionSets the URL from which connections have to be obtained. If URL is set all other properties like databasename, servername, portNumber, network protocol, tnsentry, and driver Type will be ignored.- Parameters:
url- URL to be set.- Throws:
java.sql.SQLException
-
getURL
java.lang.String getURL() throws java.sql.SQLExceptionGets the URL for this datasource. Will return the default value "jdbc:oracle:oci8:@" if not set before.- Throws:
java.sql.SQLException
-
setUser
void setUser(java.lang.String userName) throws java.sql.SQLExceptionSet the user name with which connections have to be obtained.- Parameters:
user- Username to be set.- Throws:
java.sql.SQLException
-
getUser
java.lang.String getUser()
Gets the user name for this datasource. Will return the default value ("scott") if not set before.
-
setPassword
void setPassword(java.lang.String pd) throws java.sql.SQLExceptionSets the password with which connections have to be obtained. The default value is "tiger".- Parameters:
pd- Password to be set.- Throws:
java.sql.SQLException
-
getDescription
java.lang.String getDescription()
Get the Description of this data source.- Returns:
- Description that was set or will return null if not set.
-
setDescription
void setDescription(java.lang.String des) throws java.sql.SQLExceptionSets the Description for this data source instance.- Parameters:
des- Description to be set.- Throws:
java.sql.SQLException
-
getNetworkProtocol
java.lang.String getNetworkProtocol()
Gets the network protocol set on the datasource.- Returns:
- network protocol that was set or null if not.
-
setNetworkProtocol
void setNetworkProtocol(java.lang.String np) throws java.sql.SQLExceptionSets the network protocol for the connections. Default is "tcp". Can be set to all possible protocols Net8 supports. Only needed for JDBC OCI driver.- Parameters:
np- set the network protocol to be used.- Throws:
java.sql.SQLException
-
setPortNumber
void setPortNumber(int pn) throws java.sql.SQLExceptionSets the port number where a server is listening for requests. Not required when URL is set.- Parameters:
pn- port number on which server is listening- Throws:
java.sql.SQLException
-
getPortNumber
int getPortNumber()
Gets the port number on which server is listening for requests.- Returns:
- port number if set or null if not set.
-
setConnectionProperties
void setConnectionProperties(java.util.Properties value) throws java.sql.SQLExceptionSets the Connection Properties for the datasourceThe argument to this method is a Properties object. This properties object is used to create the connections returned by the receiver. The keys and values are Strings. The keys, values, and their meanings are defined in oracle.jdbc.OracleConnection.
- Parameters:
value- a Properties object with the desired connection property names and values.- Throws:
java.sql.SQLException- See Also:
OracleConnection
-
getConnectionProperties
java.util.Properties getConnectionProperties() throws java.sql.SQLExceptionGets the connection properties that are set on this data source object. These exclude any sensitive property with "password" in its name (case-insensitive); for example, "password", "oracle.net.websocketPassword", etc.- Returns:
- A java.util.Properties object containing all the connection properties set on this data source object, excluding all sensitive properties described above. Null if there are no such connection properties set.
- Throws:
java.sql.SQLException- If any exception occurs while getting the connection properties.
-
setConnectionProperty
void setConnectionProperty(java.lang.String name, java.lang.String value) throws java.sql.SQLExceptionSets a connection property on the data source.- Parameters:
name- The name of the connection property to be set.value- The value of the connection property to be set.- Throws:
java.sql.SQLException- If any exception occurred while setting the connection property.- See Also:
setConnectionProperties(java.util.Properties),OracleConnection
-
getConnectionProperty
java.lang.String getConnectionProperty(java.lang.String propertyName) throws java.sql.SQLExceptionGets the specified connection property that is set on this data source. Any sensitive property with "password" in its name (case-insensitive, for example, "password", "oracle.net.websocketPassword", etc.) is treated as if that property were not set.- Parameters:
propertyName- The name of the specified connection property.- Returns:
- The String value of the specified connection property. Null if there is no such connection property set, or the specified connection property has "password" in its name.
- Throws:
java.sql.SQLException- If any exception occurs while getting the connection property.
-
setMaxStatements
void setMaxStatements(int max) throws java.sql.SQLExceptionSpecifies the value of the maxStatements property. This is the size of the statement cache used by both implicit and explicit caching. This value does not apply to the statement cache size of connections created by ImplicitStatementCache for which the cache size is set through a java.util.Properties object.- Parameters:
max- Requested size of the cache. If the existing cache size is less than max, statements will be purged to reduce the size.- Throws:
java.sql.SQLException- if max < 0
-
getMaxStatements
int getMaxStatements() throws java.sql.SQLExceptionReturns the current value of the maxStatements property.- Throws:
java.sql.SQLException
-
setImplicitCachingEnabled
void setImplicitCachingEnabled(boolean cache) throws java.sql.SQLExceptionSets the value of the implicitCachingEnabled property, which enables or disables the implicit statement cache. Note that this is independent of the cache size that is set with setMaxStatements().- Parameters:
cache- If true, then implicit caching is enabled. If false, then any existing statement is purged and the implicit caching is disabled.- Throws:
java.sql.SQLException
-
getImplicitCachingEnabled
boolean getImplicitCachingEnabled() throws java.sql.SQLExceptiongetImplicitCachingEnabled Returns the current value of the implicitCachingEnabled property.- Throws:
java.sql.SQLException
-
setExplicitCachingEnabled
void setExplicitCachingEnabled(boolean cache) throws java.sql.SQLExceptionSets the value of the explicitCachingEnabled property, which enables or disables the explicit cache. Note that this is independent of the cache size, which is set with setMaxStatements().- Parameters:
cache- If true, then explicit caching is enabled. If false, then any existing statement is purged and the explicit caching is disabled.- Throws:
java.sql.SQLException- if called on a logical connection.
-
getExplicitCachingEnabled
boolean getExplicitCachingEnabled() throws java.sql.SQLExceptionReturns the current value of the explicitCachingEnabled property.- Throws:
java.sql.SQLException
-
setRoleName
void setRoleName(java.lang.String roleName) throws java.sql.SQLExceptionSets the data source role name.- Parameters:
roleName- data source role name to be set.- Throws:
java.sql.SQLException
-
getRoleName
java.lang.String getRoleName()
Gets the data source role name.- Returns:
- data source role name.
-
setSSLContext
void setSSLContext(javax.net.ssl.SSLContext sslContext) throws java.sql.SQLExceptionSpecifies a
SSLContextto use as a factory for SSLEngine objects that carry out the TLS protocol.The SSLContext must be initialized before establishing a connection with this data source. 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
SSLContextpreviously set by this method- Parameters:
sslContext- An SSLContext to use as an SSLEngine factory. May be null.- Throws:
java.sql.SQLException- if this data source is incompatible with the specified SSLContext.- Since:
- 20
-
setSingleShardTransactionSupport
void setSingleShardTransactionSupport(boolean allow) throws java.sql.SQLExceptionSets single shard transaction support in auto commit OFF mode. Default value is false. Only used for the sharding driver.- Parameters:
allow-- Throws:
java.sql.SQLException- Since:
- 21
-
setHostnameResolver
void setHostnameResolver(OracleHostnameResolver hostnameResolver)
Sets a custom hostname resolver implementingOracleHostnameResolverused to provide a custom DNS name resolution strategy to locate the database host.- Parameters:
hostnameResolver- an OracleHostnameResolver to use when resolving the datasource hostname- Since:
- 23
-
setTokenSupplier
void setTokenSupplier(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Sets a supplier function that generates an access token when creating a connection with this
DataSource. The supplier function is invoked each time thisDataSourcecreates a connection. Instances ofAccessTokenthat 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
DataSourcewith both a token supplier and with a user name or password. If invocations ofsetUser(String),setPassword(String),setConnectionProperties(java.util.Properties), orsetConnectionProperty(String, String)have configured thisDataSourcewith a user name or password, and an invocation of this method has also configured a token supplier, then aSQLExceptionindicating an invalid configuration is thrown when creating a connection with this datasource.Note that
AccessToken.createJsonWebTokenCache(Supplier)can be called to create a thread safeSupplierthat caches tokens from a user definedSupplier.- Parameters:
tokenSupplier- Token supplying function. Notnull.- Throws:
java.lang.NullPointerException- If thetokenSupplieris null.
-
-