Class OracleDataSource
- java.lang.Object
-
- oracle.jdbc.datasource.impl.OracleDataSource
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.io.Serializable
,java.sql.Wrapper
,java.util.EventListener
,javax.naming.Referenceable
,javax.sql.CommonDataSource
,javax.sql.DataSource
,OracleCommonDataSource
,OracleDataSource
,oracle.jdbc.diagnostics.Diagnosable
,oracle.jdbc.internal.Monitor
,oracle.jdbc.replay.internal.OracleDataSource
,OracleDataSource
- Direct Known Subclasses:
OracleConnectionPoolDataSource
,OracleDataSource
,OracleDataSourceImpl
public class OracleDataSource extends java.lang.Object implements OracleDataSource, oracle.jdbc.diagnostics.Diagnosable, oracle.jdbc.replay.internal.OracleDataSource, java.io.Serializable, javax.naming.Referenceable, oracle.jdbc.internal.Monitor
A
DataSource
object is a factory forConnection
objects. An object that implements theDataSource
interface will typically be registered with a JNDI service provider. A JDBC driver that is accessed via theDataSource
API does not automatically register itself with theDriverManager
.This data Source supports Application Continuity (AC) and transparent JDBC operation replay upon a failover. To disable such feature, set
"oracle.jdbc.enableACSupport"
to false either as a Java system property, or as a connection property on this data source.The following example illustrates the use of this data source to create a JDBC connection:
oracle.jdbc.datasource.OracleDataSource ods = new oracle.jdbc.datasource.impl.OracleDataSource(); ods.setURL("jdbc:oracle:thin:@//dbhost:dbport/dbservice"); ods.setUser("User"); ods.setPassword("Passwd"); ods.setConnectionProperty("connProp1", "value1"); ods.setConnectionProperty("connProp2", "value2"); Connection conn = ods.getConnection();
The following example illustrates the use of a connection obtained from this data source for Application Continuity protection:
oracle.jdbc.OracleConnection conn = (oracle.jdbc.OracleConnection) ods.getConnection(); conn.beginRequest(); ...... // JDBC calls protected by AC conn.endRequest();
- Since:
- 20c
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CHECKSUM_PROPERTY
protected java.lang.String
clientChecksum11203x
protected java.lang.String
clientChecksum12x
protected java.util.Properties
connectionProperties
protected java.lang.String
databaseName
protected java.lang.String
dataSourceName
protected static java.lang.String
DEFAULT_SERVICE_NAME
protected java.lang.String
description
protected static java.lang.String
DMS_DEFAULT_DATASOURCE_NAME
protected static java.lang.String
DMS_ROOT_NAME
protected java.util.concurrent.atomic.AtomicBoolean
doneDumpOnMemoryPressure
protected oracle.jdbc.driver.OracleDriver
driver
protected java.lang.String
driverType
protected static java.lang.String
ENABLE_AC_SUPPORT_PROPERTY
protected static java.lang.String
ENABLE_SSS_CURSOR_SUPPORT_PROPERTY
protected boolean
explicitCachingEnabled
protected boolean
explicitCachingEnabledSet
protected static int
FAILOVER_RESTORE_AUTO
protected static int
FAILOVER_RESTORE_LEVEL1
protected static int
FAILOVER_RESTORE_LEVEL2
protected static int
FAILOVER_RESTORE_NONE
protected static java.lang.String
FAILOVER_RESTORE_PROPERTY
protected static int
FAILOVER_TYPE_AUTO
protected static int
FAILOVER_TYPE_ON_REMOTE
protected static java.lang.String
FAILOVER_TYPE_PROPERTY
protected static int
FAILOVER_TYPE_TRANSACTION
protected static java.lang.String
IGNORE_AC_CONTEXT_PROPERTY
protected boolean
implicitCachingEnabled
protected boolean
implicitCachingEnabledSet
protected static java.lang.String
INITIATION_TIMEOUT_PROPERTY
protected boolean
isAutoACEnabled
protected java.util.concurrent.atomic.AtomicBoolean
isFirstConnection
protected boolean
isHybrid
boolean
isOracleDataSource
protected boolean
isReplayInDynamicMode
protected boolean
isSSSCursorEnabled
protected boolean
isStateRestorationAuto
protected boolean
isTransactionReplayEnabled
protected int
loginTimeout
protected java.io.PrintWriter
logWriter
protected int
maxStatements
protected boolean
maxStatementsSet
protected java.lang.String
networkProtocol
protected oracle.jdbc.internal.OpaqueString
password
protected int
portNumber
protected static java.lang.String
RECONNECT_DELAY_PROPERTY
protected static java.lang.String
RECONNECT_RETRIES_PROPERTY
protected int
reconnectDelay
protected int
reconnectRetries
protected int
replayInitiationTimeout
protected static java.lang.String
REQUEST_SIZE_LIMIT_PROPERTY
protected java.lang.String
serverName
protected java.lang.String
serviceName
protected static int
SESSION_STATE_CONSISTENCY_HYBRID
protected static int
SESSION_STATE_CONSISTENCY_STATIC
protected static java.lang.String
SESSION_STATE_PROPERTY
protected oracle.jdbc.replay.internal.ReplayableConnection.StateRestorationType
stateRestorationType
protected java.lang.String
tnsEntry
static boolean
TRACE
protected java.util.concurrent.atomic.AtomicBoolean
trackerInitialized
protected static int
unnamedInstanceCount
protected java.lang.String
url
protected java.lang.String
user
-
Fields inherited from interface oracle.jdbc.replay.OracleDataSource
CONNECTION_PROPERTIES, DATA_SOURCE_NAME, DATABASE_NAME, DESCRIPTION, EXPLICIT_CACHING_ENABLED, IMPLICIT_CACHING_ENABLED, MAX_STATEMENTS, NETWORK_PROTOCOL, PASSWORD, PORT_NUMBER, ROLE_NAME, SERVER_NAME, URL, USER
-
-
Constructor Summary
Constructors Constructor Description OracleDataSource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
addRefProperties(javax.naming.Reference ref)
static void
cleanup()
void
clearDoneDumpOnMemoryPressure()
void
clearReplayStatistics()
Clears replay statistics accumulated so far on all connection created by this data source.OracleConnectionBuilderImpl
createConnectionBuilder()
Creates a new instanceprotected static java.lang.String
dms_data_source_type()
protected java.sql.Connection
enableACAndProxifyIfNecessary(java.sql.Connection conn, OracleConnectionBuilderImpl connBuilder)
protected void
finalize()
java.sql.Connection
getConnection()
Attempt to establish a database connection.java.sql.Connection
getConnection(java.lang.String user, java.lang.String password)
Attempt to establish a database connection.protected java.sql.Connection
getConnection(java.lang.String _user, oracle.jdbc.internal.OpaqueString _passwd)
Attempt to establish a database connection.protected java.sql.Connection
getConnection(OracleConnectionBuilderImpl builder)
Attempt to establish a database connection.protected oracle.jdbc.internal.OracleConnection
getConnectionDuringExceptionHandling()
oracle.jdbc.replay.internal.ConnectionInitializationCallback
getConnectionInitializationCallback()
Obtains the registered connection initialization callback, if any.java.sql.Connection
getConnectionNoProxy(OracleConnectionBuilderImpl connBuilder)
java.util.Properties
getConnectionProperties()
Gets the connection properties that are set on this data source object.java.lang.String
getConnectionProperty(java.lang.String propertyName)
Gets the specified connection property that is set on this data source.java.lang.String
getDatabaseName()
Get the name of the database set on this DataSource instance.java.lang.String
getDataSourceName()
Get the datasource name for this instance if set.java.lang.String
getDescription()
Get the Desciption of this data source.oracle.jdbc.diagnostics.Diagnosable
getDiagnosable()
AC specifcjava.lang.String
getDriverType()
Get the Oracle JDBC driver type set for this datasource instanceboolean
getExplicitCachingEnabled()
getExplicitCachingEnabled Returns the current value of the explicitCachingEnabled property.boolean
getImplicitCachingEnabled()
getImplicitCachingEnabled Returns the current value of the implicitCachingEnabled property.int
getLoginTimeout()
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.java.io.PrintWriter
getLogWriter()
Get the log writer for this data source.int
getMaxStatements()
getMaxStatements Returns the current value of the maxStatements property.oracle.jdbc.internal.Monitor.CloseableLock
getMonitorLock()
java.lang.String
getNetworkProtocol()
Get the network protocol set.java.util.logging.Logger
getParentLogger()
protected oracle.jdbc.internal.OpaqueString
getPassword()
protected java.sql.Connection
getPhysicalConnection(java.util.Properties prop, oracle.jdbc.internal.AbstractConnectionBuilder builder)
Get a connection to the database specified by this datasource.int
getPortNumber()
Get the port number on which server is listening for requests.oracle.jdbc.proxy.ProxyFactory
getProxyFactory()
javax.naming.Reference
getReference()
ReplayStatistics
getReplayStatistics()
Obtains replay statistics accumulated so far.java.lang.String
getReplayStatisticsString()
int
getRequestSizeLimit()
java.lang.String
getRoleName()
Gets the datasource role name.java.lang.String
getServerName()
Get the name of the server on which database is running.java.lang.String
getServiceName()
Get the service_name To distinguish services from instances, a new URL using service_name is added, existing url with SID will be supported, but deprecated.protected boolean
getSSSCursorProperty()
protected static java.lang.String
getSystemProperty(java.lang.String property, java.lang.String defaultValue)
java.lang.String
getTNSEntryName()
Get the TNS entry name for this instance if set.java.lang.String
getURL()
Get the URL for this datasource.java.lang.String
getUser()
Get the user name for this datasource.boolean
isWrapperFor(java.lang.Class<?> iface)
Since this class is not a wrapper, just check to see if this implements the requested interface.protected void
makeURL()
void
registerConnectionInitializationCallback(oracle.jdbc.replay.internal.ConnectionInitializationCallback cbk)
Registers a ConnectionInitializationCallback with the data source.static void
registerMBean()
void
removeReplayStatistics(oracle.jdbc.replay.internal.ReplayStatistics stats)
void
setConnectionProperties(java.util.Properties properties)
Sets the Connection Properties for the datasourcevoid
setConnectionProperty(java.lang.String name, java.lang.String value)
Sets a connection property on the data source.void
setDatabaseName(java.lang.String dbname)
Set the name of a particular database on a server.void
setDataSourceName(java.lang.String dsname)
Set the DataSourceName.void
setDescription(java.lang.String des)
Set the Desciption for this data source instance.void
setDriverType(java.lang.String dt)
Set the JDBC driver type.void
setExplicitCachingEnabled(boolean cache)
setExplicitCachingEnabled Sets the value of the explicitCachingEnabled property, which enables or disables the explicit cache.void
setHostnameResolver(OracleHostnameResolver hostnameResolver)
Sets a custom hostname resolver implementingOracleHostnameResolver
used to provide a custom DNS name resolution strategy to locate the database host.void
setImplicitCachingEnabled(boolean cache)
setImplicitCachingEnabled Sets the value of the implicitCachingEnabled property, which enables or disables the implicit cache.void
setLoginTimeout(int timeout)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.void
setLogWriter(java.io.PrintWriter pw)
Set the log writer for this data source.void
setMaxStatements(int max)
Deprecated.void
setNetworkProtocol(java.lang.String np)
Set the network protocol for the connections.void
setPassword(java.lang.String pd)
Set the password with which connections have to be obtained.void
setPortNumber(int pn)
Set the port number where a server is listening for requests.void
setRoleName(java.lang.String roleName)
Sets the datasource role name.void
setServerName(java.lang.String sn)
Set the name of the Server on which database is running.void
setServiceName(java.lang.String svcname)
Set the service_name of a database on a server.void
setSingleShardTransactionSupport(boolean allow)
Sets single shard transaction support in auto commit OFF mode.void
setSSLContext(javax.net.ssl.SSLContext sslContext)
Specifies aSSLContext
to use as a factory for SSLEngine objects that carry out the TLS protocol.void
setTNSEntryName(java.lang.String dbname)
Set the TNS entry name.void
setTokenSupplier(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Sets a supplier function that generates an access token when creating a connection with thisDataSource
.protected void
setupACSpecificProperties(boolean useProxy)
void
setURL(java.lang.String url)
Set the URL from which connections have to be obtained.void
setUser(java.lang.String userName)
Set the user name with which connections have to be obtained.void
unregisterConnectionInitializationCallback(oracle.jdbc.replay.internal.ConnectionInitializationCallback cbk)
Removes the ConnectionInitializationCallback registered with the data source, if any.static void
unregisterMBean()
<T> T
unwrap(java.lang.Class<T> iface)
Since this class is not a wrapper, just check to see if this implements the requested interface.void
updateReplayStatistics(oracle.jdbc.replay.internal.ReplayStatistics newStats)
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface oracle.jdbc.diagnostics.Diagnosable
begin, begin, beginCurrentSql, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debugp, end, end, endCurrentSql, format, isDebugEnabled, isDiagnoseFirstFailureEnabled, isLoggable, isSensitiveEnabled, onClose, propertyChange, resumeLogging, secure, suspendLogging, trace, tracep
-
Methods inherited from interface oracle.jdbc.internal.Monitor
acquireCloseableLock, acquireLock, releaseLock
-
Methods inherited from interface oracle.jdbc.datasource.OracleCommonDataSource
createShardingKeyBuilder
-
-
-
-
Field Detail
-
unnamedInstanceCount
protected static int unnamedInstanceCount
-
DMS_ROOT_NAME
protected static final java.lang.String DMS_ROOT_NAME
- See Also:
- Constant Field Values
-
DMS_DEFAULT_DATASOURCE_NAME
protected static final java.lang.String DMS_DEFAULT_DATASOURCE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_SERVICE_NAME
protected static final java.lang.String DEFAULT_SERVICE_NAME
- See Also:
- Constant Field Values
-
logWriter
protected java.io.PrintWriter logWriter
-
loginTimeout
protected int loginTimeout
-
databaseName
protected java.lang.String databaseName
-
serviceName
protected java.lang.String serviceName
-
dataSourceName
protected java.lang.String dataSourceName
-
description
protected java.lang.String description
-
networkProtocol
protected java.lang.String networkProtocol
-
portNumber
protected int portNumber
-
user
protected java.lang.String user
-
password
protected oracle.jdbc.internal.OpaqueString password
-
serverName
protected java.lang.String serverName
-
url
protected java.lang.String url
-
driverType
protected java.lang.String driverType
-
tnsEntry
protected java.lang.String tnsEntry
-
maxStatements
protected int maxStatements
-
implicitCachingEnabled
protected boolean implicitCachingEnabled
-
explicitCachingEnabled
protected boolean explicitCachingEnabled
-
maxStatementsSet
protected boolean maxStatementsSet
-
implicitCachingEnabledSet
protected boolean implicitCachingEnabledSet
-
explicitCachingEnabledSet
protected boolean explicitCachingEnabledSet
-
connectionProperties
protected java.util.Properties connectionProperties
-
isOracleDataSource
public boolean isOracleDataSource
-
driver
protected transient oracle.jdbc.driver.OracleDriver driver
-
isFirstConnection
protected java.util.concurrent.atomic.AtomicBoolean isFirstConnection
-
RECONNECT_DELAY_PROPERTY
protected static final java.lang.String RECONNECT_DELAY_PROPERTY
- See Also:
- Constant Field Values
-
RECONNECT_RETRIES_PROPERTY
protected static final java.lang.String RECONNECT_RETRIES_PROPERTY
- See Also:
- Constant Field Values
-
reconnectDelay
protected int reconnectDelay
-
reconnectRetries
protected int reconnectRetries
-
FAILOVER_TYPE_PROPERTY
protected static final java.lang.String FAILOVER_TYPE_PROPERTY
- See Also:
- Constant Field Values
-
FAILOVER_TYPE_TRANSACTION
protected static final int FAILOVER_TYPE_TRANSACTION
- See Also:
- Constant Field Values
-
SESSION_STATE_CONSISTENCY_STATIC
protected static final int SESSION_STATE_CONSISTENCY_STATIC
- See Also:
- Constant Field Values
-
FAILOVER_TYPE_AUTO
protected static final int FAILOVER_TYPE_AUTO
- See Also:
- Constant Field Values
-
SESSION_STATE_CONSISTENCY_HYBRID
protected static final int SESSION_STATE_CONSISTENCY_HYBRID
- See Also:
- Constant Field Values
-
FAILOVER_TYPE_ON_REMOTE
protected static final int FAILOVER_TYPE_ON_REMOTE
- See Also:
- Constant Field Values
-
isTransactionReplayEnabled
protected boolean isTransactionReplayEnabled
-
isAutoACEnabled
protected boolean isAutoACEnabled
-
SESSION_STATE_PROPERTY
protected static final java.lang.String SESSION_STATE_PROPERTY
- See Also:
- Constant Field Values
-
isReplayInDynamicMode
protected boolean isReplayInDynamicMode
-
isHybrid
protected boolean isHybrid
-
FAILOVER_RESTORE_PROPERTY
protected static final java.lang.String FAILOVER_RESTORE_PROPERTY
- See Also:
- Constant Field Values
-
FAILOVER_RESTORE_NONE
protected static final int FAILOVER_RESTORE_NONE
- See Also:
- Constant Field Values
-
FAILOVER_RESTORE_LEVEL1
protected static final int FAILOVER_RESTORE_LEVEL1
- See Also:
- Constant Field Values
-
FAILOVER_RESTORE_LEVEL2
protected static final int FAILOVER_RESTORE_LEVEL2
- See Also:
- Constant Field Values
-
FAILOVER_RESTORE_AUTO
protected static final int FAILOVER_RESTORE_AUTO
- See Also:
- Constant Field Values
-
stateRestorationType
protected oracle.jdbc.replay.internal.ReplayableConnection.StateRestorationType stateRestorationType
-
isStateRestorationAuto
protected boolean isStateRestorationAuto
-
INITIATION_TIMEOUT_PROPERTY
protected static final java.lang.String INITIATION_TIMEOUT_PROPERTY
- See Also:
- Constant Field Values
-
replayInitiationTimeout
protected int replayInitiationTimeout
-
CHECKSUM_PROPERTY
protected static final java.lang.String CHECKSUM_PROPERTY
- See Also:
- Constant Field Values
-
clientChecksum12x
protected final java.lang.String clientChecksum12x
-
clientChecksum11203x
protected final java.lang.String clientChecksum11203x
-
IGNORE_AC_CONTEXT_PROPERTY
protected static final java.lang.String IGNORE_AC_CONTEXT_PROPERTY
- See Also:
- Constant Field Values
-
ENABLE_AC_SUPPORT_PROPERTY
protected static final java.lang.String ENABLE_AC_SUPPORT_PROPERTY
- See Also:
- Constant Field Values
-
REQUEST_SIZE_LIMIT_PROPERTY
protected static final java.lang.String REQUEST_SIZE_LIMIT_PROPERTY
- See Also:
- Constant Field Values
-
ENABLE_SSS_CURSOR_SUPPORT_PROPERTY
protected static final java.lang.String ENABLE_SSS_CURSOR_SUPPORT_PROPERTY
- See Also:
- Constant Field Values
-
isSSSCursorEnabled
protected boolean isSSSCursorEnabled
-
trackerInitialized
protected final java.util.concurrent.atomic.AtomicBoolean trackerInitialized
-
doneDumpOnMemoryPressure
protected java.util.concurrent.atomic.AtomicBoolean doneDumpOnMemoryPressure
-
TRACE
public static final boolean TRACE
- See Also:
- Constant Field Values
-
-
Method Detail
-
dms_data_source_type
protected static java.lang.String dms_data_source_type()
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
Attempt to establish a database connection.
- Specified by:
getConnection
in interfacejavax.sql.DataSource
- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
getConnection
public java.sql.Connection getConnection(java.lang.String user, java.lang.String password) throws java.sql.SQLException
Attempt to establish a database connection.
- Specified by:
getConnection
in interfacejavax.sql.DataSource
- Parameters:
user
- the database user on whose behalf the Connection is being madepassword
- the user's password- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
getConnection
protected java.sql.Connection getConnection(java.lang.String _user, oracle.jdbc.internal.OpaqueString _passwd) throws java.sql.SQLException
Attempt to establish a database connection.
- Parameters:
_user
- the database user on whose behalf the Connection is being made_passwd
- the user's password- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
getConnection
protected java.sql.Connection getConnection(OracleConnectionBuilderImpl builder) throws java.sql.SQLException
Attempt to establish a database connection.
- Parameters:
builder
- Builder which has the required properties set for building the connection- Returns:
- a Connection to the database
- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
getPhysicalConnection
protected java.sql.Connection getPhysicalConnection(java.util.Properties prop, oracle.jdbc.internal.AbstractConnectionBuilder builder) throws java.sql.SQLException
Get a connection to the database specified by this datasource.- Parameters:
prop
- Connection properties specified on this datasource.builder
- The builder object used to create the connection. May be null if a builder was not used to create the connection.- Returns:
- A database connection
- Throws:
java.sql.SQLException
-
getLoginTimeout
public int getLoginTimeout()
Gets the maximum time in seconds that this data source can wait while attempting to connect to a database. A value of zero means that the timeout is the default system timeout if there is one; otherwise it means that there is no timeout. When a DataSource object is created the login timeout is initially zero.- Specified by:
getLoginTimeout
in interfacejavax.sql.CommonDataSource
- Specified by:
getLoginTimeout
in interfacejavax.sql.DataSource
- Returns:
- the data source login time limit
- Throws:
java.sql.SQLException
- if a database access error occurs.
-
setLoginTimeout
public void setLoginTimeout(int timeout)
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise it specifies that there is no timeout. When a DataSource object is created the login timeout is initially zero.
- Specified by:
setLoginTimeout
in interfacejavax.sql.CommonDataSource
- Specified by:
setLoginTimeout
in interfacejavax.sql.DataSource
- Parameters:
seconds
- the data source login time limit- Throws:
java.sql.SQLException
- if a database access error occurs.
-
setLogWriter
public void setLogWriter(java.io.PrintWriter pw)
Set the log writer for this data source.
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.
- Specified by:
setLogWriter
in interfacejavax.sql.CommonDataSource
- Specified by:
setLogWriter
in interfacejavax.sql.DataSource
- Parameters:
out
- the new log writer; to disable, set to null- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
getLogWriter
public java.io.PrintWriter getLogWriter()
Get the log writer for this data source.
The log writer is a character output stream to which all logging and tracing messages for this data source object instance will be printed. This includes messages printed by the methods of this object, messages printed by methods of other objects manufactured by this object, and so on. Messages printed to a data source specific log writer are not printed to the log writer associated with the java.sql.Drivermanager class. When a DataSource object is created the log writer is initially null, in other words, logging is disabled.
- Specified by:
getLogWriter
in interfacejavax.sql.CommonDataSource
- Specified by:
getLogWriter
in interfacejavax.sql.DataSource
- Returns:
- the log writer for this data source, null if disabled
- Throws:
java.sql.SQLException
- if a database-access error occurs.
-
setTNSEntryName
public void setTNSEntryName(java.lang.String dbname)
Set the TNS entry name. Works only for JDBC OCI driver. Assumed that client side Oracle in installed and TNS_ADMIN env variable is set. If URL is set, this property will be ignored.- Parameters:
dbname
- tns entry name
-
getTNSEntryName
public java.lang.String getTNSEntryName()
Get the TNS entry name for this instance if set. Returns null if not set.- Returns:
- TNS entry name
-
setDataSourceName
public void setDataSourceName(java.lang.String dsname)
Set the DataSourceName. Users need not set this as it will be set set automatically depending upon the instance created. Returns OracleDataSource for an OracleDataSource instance. Returns OracleXADataSource for an OracleXADataSource instance.- Specified by:
setDataSourceName
in interfaceOracleCommonDataSource
- Parameters:
dsname
- DataSource Name to be set.
-
getDataSourceName
public java.lang.String getDataSourceName()
Get the datasource name for this instance if set. Returns null if not set.- Specified by:
getDataSourceName
in interfaceOracleCommonDataSource
- Returns:
- DaraSource name
-
getDatabaseName
public java.lang.String getDatabaseName()
Get the name of the database set on this DataSource instance.- Specified by:
getDatabaseName
in interfaceOracleCommonDataSource
- Returns:
- database name set on this instance or null if not set.
-
setDatabaseName
public void setDatabaseName(java.lang.String dbname)
Set 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.
- Specified by:
setDatabaseName
in interfaceOracleCommonDataSource
- Parameters:
dsname
- database name to be set.
-
setServiceName
public void setServiceName(java.lang.String svcname)
Set the service_name of a database on a server. If URL is set, this property will be ignored. To distinguish services from instances, a new URL using service_name is added, existing url with SID will be supported, but deprecated.- Parameters:
svcname
- service_name to be set.
-
getServiceName
public java.lang.String getServiceName()
Get the service_name To distinguish services from instances, a new URL using service_name is added, existing url with SID will be supported, but deprecated.- Returns:
- service_name assiciated with the instance or null if not set.
-
setServerName
public void setServerName(java.lang.String sn)
Set the name of the Server on which database is running. If URL is set, this property will be ignored.- Specified by:
setServerName
in interfaceOracleCommonDataSource
- Parameters:
sn
- server/host name to be set.
-
getServerName
public java.lang.String getServerName()
Get the name of the server on which database is running.- Specified by:
getServerName
in interfaceOracleCommonDataSource
- Returns:
- server name set on this instance or null if not set.
-
setURL
public void setURL(java.lang.String url)
Set 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.- Specified by:
setURL
in interfaceOracleCommonDataSource
- Parameters:
url
- URL to be set.
-
getURL
public java.lang.String getURL() throws java.sql.SQLException
Get the URL for this datasource. Will return the default value "jdbc:oracle:oci8:@" if not set before.- Specified by:
getURL
in interfaceOracleCommonDataSource
- Throws:
java.sql.SQLException
-
setUser
public void setUser(java.lang.String userName)
Set the user name with which connections have to be obtained.- Specified by:
setUser
in interfaceOracleCommonDataSource
- Parameters:
user
- Username to be set.
-
getUser
public java.lang.String getUser()
Get the user name for this datasource. Will return the default value ("scott") if not set before.- Specified by:
getUser
in interfaceOracleCommonDataSource
-
setPassword
public void setPassword(java.lang.String pd)
Set the password with which connections have to be obtained. The default value is "tiger".- Specified by:
setPassword
in interfaceOracleCommonDataSource
- Parameters:
pd
- Passowrd to be set.
-
getPassword
protected oracle.jdbc.internal.OpaqueString getPassword()
-
getDescription
public java.lang.String getDescription()
Get the Desciption of this data source.- Specified by:
getDescription
in interfaceOracleCommonDataSource
- Returns:
- Description that was set or will return null if not set.
-
setDescription
public void setDescription(java.lang.String des)
Set the Desciption for this data source instance.- Specified by:
setDescription
in interfaceOracleCommonDataSource
- Parameters:
des
- Desciption to be set.
-
getDriverType
public java.lang.String getDriverType()
Get the Oracle JDBC driver type set for this datasource instance- Returns:
- Driver Type that was set or null if not set.
-
setDriverType
public void setDriverType(java.lang.String dt)
Set the JDBC driver type. Possible values are thin, oci8, and kprb. If URL is set, this property will be ignored.If set to kprb, nothing else is needed to open a connection. This is meant for Server side JDBC driver when running inside server.
If set to thin, serverName, portNumber and databaseName are need to open a connection.
If set to oci, and network protocol is set to IPC or TNSEntryName is set then nothing else is needed. If not, serverName, portNumber and databaseName have to be provided.
- Parameters:
dt
- Driver Type tp be set.
-
getNetworkProtocol
public java.lang.String getNetworkProtocol()
Get the network protocol set.- Specified by:
getNetworkProtocol
in interfaceOracleCommonDataSource
- Returns:
- network protocol that was set or null if not.
-
setNetworkProtocol
public void setNetworkProtocol(java.lang.String np) throws java.sql.SQLException
Set the network protocol for the connections. Default is "tcp". Can be set to all possible protocols Net8 supports. Only needed for JDBC OCI driver.- Specified by:
setNetworkProtocol
in interfaceOracleCommonDataSource
- Parameters:
np
- set the network protocol to be used.- Throws:
java.sql.SQLException
-
setPortNumber
public void setPortNumber(int pn)
Set the port number where a server is listening for requests. Not required when URL is set.- Specified by:
setPortNumber
in interfaceOracleCommonDataSource
- Parameters:
pn
- port number on which server is listening
-
getPortNumber
public int getPortNumber()
Get the port number on which server is listening for requests.- Specified by:
getPortNumber
in interfaceOracleCommonDataSource
- Returns:
- port number if set or null if not set.
-
getReference
public javax.naming.Reference getReference() throws javax.naming.NamingException
- Specified by:
getReference
in interfacejavax.naming.Referenceable
- Throws:
javax.naming.NamingException
-
addRefProperties
protected void addRefProperties(javax.naming.Reference ref)
-
makeURL
protected void makeURL() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setMaxStatements
public void setMaxStatements(int max) throws java.sql.SQLException
Deprecated.setMaxStatements Specifies the value of the maxStatements property. This will be the size of the application cache (which will be 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 java.util.Properties object.- Specified by:
setMaxStatements
in interfaceOracleCommonDataSource
- Specified by:
setMaxStatements
in interfaceOracleDataSource
- 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
public int getMaxStatements() throws java.sql.SQLException
getMaxStatements Returns the current value of the maxStatements property.- Specified by:
getMaxStatements
in interfaceOracleCommonDataSource
- Specified by:
getMaxStatements
in interfaceOracleDataSource
- Throws:
java.sql.SQLException
-
setImplicitCachingEnabled
public void setImplicitCachingEnabled(boolean cache) throws java.sql.SQLException
setImplicitCachingEnabled Sets the value of the implicitCachingEnabled property, which enables or disables the implicit cache. Note that this is independent of the cache size, set with setMaxStatements().- Specified by:
setImplicitCachingEnabled
in interfaceOracleCommonDataSource
- Specified by:
setImplicitCachingEnabled
in interfaceOracleDataSource
- Parameters:
cache
- If true, then implicit caching will be enabled. If false, then any existing statements will be purged and the implicit cache will be disabled.- Throws:
java.sql.SQLException
-
getImplicitCachingEnabled
public boolean getImplicitCachingEnabled() throws java.sql.SQLException
getImplicitCachingEnabled Returns the current value of the implicitCachingEnabled property.- Specified by:
getImplicitCachingEnabled
in interfaceOracleCommonDataSource
- Specified by:
getImplicitCachingEnabled
in interfaceOracleDataSource
- Throws:
java.sql.SQLException
-
setExplicitCachingEnabled
public void setExplicitCachingEnabled(boolean cache) throws java.sql.SQLException
setExplicitCachingEnabled Sets the value of the explicitCachingEnabled property, which enables or disables the explicit cache. Note that this is independent of the cache size, set with setMaxStatements().- Specified by:
setExplicitCachingEnabled
in interfaceOracleCommonDataSource
- Specified by:
setExplicitCachingEnabled
in interfaceOracleDataSource
- Parameters:
cache
- If true, then explicit caching will be enabled. If false, then any existing statements will be purged and the explicit cache will be disabled.- Throws:
java.sql.SQLException
- if called on a logical connection.
-
getExplicitCachingEnabled
public boolean getExplicitCachingEnabled() throws java.sql.SQLException
getExplicitCachingEnabled Returns the current value of the explicitCachingEnabled property.- Specified by:
getExplicitCachingEnabled
in interfaceOracleCommonDataSource
- Specified by:
getExplicitCachingEnabled
in interfaceOracleDataSource
- Throws:
java.sql.SQLException
-
setConnectionProperties
public void setConnectionProperties(java.util.Properties properties) throws java.sql.SQLException
Sets 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.
- Specified by:
setConnectionProperties
in interfaceOracleCommonDataSource
- Parameters:
properties
- a Properties object with the desired connection property names and values.- Throws:
java.sql.SQLException
- See Also:
OracleConnection
-
setRoleName
public void setRoleName(java.lang.String roleName) throws java.sql.SQLException
Sets the datasource role name.- Specified by:
setRoleName
in interfaceOracleCommonDataSource
- Specified by:
setRoleName
in interfaceOracleDataSource
- Parameters:
roleName
- datasource role name to be set.- Throws:
java.sql.SQLException
-
getRoleName
public java.lang.String getRoleName()
Gets the datasource role name.- Specified by:
getRoleName
in interfaceOracleCommonDataSource
- Specified by:
getRoleName
in interfaceOracleDataSource
- Returns:
- datasource role name.
-
getConnectionProperties
public java.util.Properties getConnectionProperties() throws java.sql.SQLException
Gets 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.- Specified by:
getConnectionProperties
in interfaceOracleCommonDataSource
- 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.
-
getConnectionProperty
public java.lang.String getConnectionProperty(java.lang.String propertyName) throws java.sql.SQLException
Gets 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.- Specified by:
getConnectionProperty
in interfaceOracleCommonDataSource
- 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.
-
setConnectionProperty
public void setConnectionProperty(java.lang.String name, java.lang.String value) throws java.sql.SQLException
Sets a connection property on the data source.- Specified by:
setConnectionProperty
in interfaceOracleCommonDataSource
- 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)
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException
Since this class is not a wrapper, just check to see if this implements the requested interface.- Specified by:
isWrapperFor
in interfacejava.sql.Wrapper
- Parameters:
iface
- requested interface- Returns:
- true iff this implements the requested interface
- Throws:
java.sql.SQLException
- if the arg is not an interface- Since:
- JDBC 4.0
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException
Since this class is not a wrapper, just check to see if this implements the requested interface. If it does return this.- Specified by:
unwrap
in interfacejava.sql.Wrapper
- Parameters:
iface
- requested interface- Returns:
- this iff this implements the requested interface
- Throws:
java.sql.SQLException
- if this does not implement the arg or the arg is not an interface- Since:
- JDBC 4.0
-
getParentLogger
public java.util.logging.Logger getParentLogger() throws java.sql.SQLFeatureNotSupportedException
- Specified by:
getParentLogger
in interfacejavax.sql.CommonDataSource
- Throws:
java.sql.SQLFeatureNotSupportedException
-
setSSLContext
public final void setSSLContext(javax.net.ssl.SSLContext sslContext)
Description copied from interface:OracleCommonDataSource
Specifies aSSLContext
to use as a factory for SSLEngine objects that carry out the TLS protocol.The SSLContext must be initialized before establishing a connection to the 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 value that may have been set previously, causing this data source to behave as if this method had never been called at all.
- Specified by:
setSSLContext
in interfaceOracleCommonDataSource
- Parameters:
sslContext
- An SSLContext to use as an SSLEngine factory.
-
setSingleShardTransactionSupport
public void setSingleShardTransactionSupport(boolean allow) throws java.sql.SQLException
Description copied from interface:OracleCommonDataSource
Sets single shard transaction support in auto commit OFF mode. Default value is false. Only used for the sharding driver.- Specified by:
setSingleShardTransactionSupport
in interfaceOracleCommonDataSource
- Throws:
java.sql.SQLException
-
setHostnameResolver
public void setHostnameResolver(OracleHostnameResolver hostnameResolver)
Description copied from interface:OracleCommonDataSource
Sets a custom hostname resolver implementingOracleHostnameResolver
used to provide a custom DNS name resolution strategy to locate the database host.- Specified by:
setHostnameResolver
in interfaceOracleCommonDataSource
- Parameters:
hostnameResolver
- an OracleHostnameResolver to use when resolving the datasource hostname
-
getConnectionDuringExceptionHandling
protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()
-
createConnectionBuilder
public OracleConnectionBuilderImpl createConnectionBuilder()
Creates a new instance- Specified by:
createConnectionBuilder
in interfacejavax.sql.DataSource
- Specified by:
createConnectionBuilder
in interfaceOracleDataSource
- Returns:
- The OracleConnectionBuilder instance that was created
-
getConnectionNoProxy
public java.sql.Connection getConnectionNoProxy(OracleConnectionBuilderImpl connBuilder) throws java.sql.SQLException
- Specified by:
getConnectionNoProxy
in interfaceoracle.jdbc.replay.internal.OracleDataSource
- Throws:
java.sql.SQLException
-
setupACSpecificProperties
protected void setupACSpecificProperties(boolean useProxy) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
enableACAndProxifyIfNecessary
protected java.sql.Connection enableACAndProxifyIfNecessary(java.sql.Connection conn, OracleConnectionBuilderImpl connBuilder) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
registerConnectionInitializationCallback
public void registerConnectionInitializationCallback(oracle.jdbc.replay.internal.ConnectionInitializationCallback cbk) throws java.sql.SQLException
Registers a ConnectionInitializationCallback with the data source.- Specified by:
registerConnectionInitializationCallback
in interfaceOracleDataSource
- Parameters:
cbk
- The ConnectionInitializationCallback to be registered.- Throws:
java.sql.SQLException
- If the argument is null or callback registration fails.
-
unregisterConnectionInitializationCallback
public void unregisterConnectionInitializationCallback(oracle.jdbc.replay.internal.ConnectionInitializationCallback cbk) throws java.sql.SQLException
Removes the ConnectionInitializationCallback registered with the data source, if any.- Specified by:
unregisterConnectionInitializationCallback
in interfaceOracleDataSource
- Parameters:
cbk
- TheConnectionInitializationCallback
object to be unregistered.- Throws:
java.sql.SQLException
- If callback removal fails.
-
getConnectionInitializationCallback
public oracle.jdbc.replay.internal.ConnectionInitializationCallback getConnectionInitializationCallback()
Description copied from interface:OracleDataSource
Obtains the registered connection initialization callback, if any.- Specified by:
getConnectionInitializationCallback
in interfaceOracleDataSource
- Returns:
- The registered
ConnectionInitializationCallback
, or null if there is no callback registered.
-
getReplayStatistics
public ReplayStatistics getReplayStatistics()
Description copied from interface:OracleDataSource
Obtains replay statistics accumulated so far. These reflect replay actions across all the connections created by this data source. It is recommended that this call be made when the connections are quiescent and there are few new connections being opened.- Specified by:
getReplayStatistics
in interfaceOracleDataSource
- Returns:
- A replay statistics object containing all the metrics.
-
clearDoneDumpOnMemoryPressure
public void clearDoneDumpOnMemoryPressure()
- Specified by:
clearDoneDumpOnMemoryPressure
in interfaceoracle.jdbc.replay.internal.OracleDataSource
-
getReplayStatisticsString
public java.lang.String getReplayStatisticsString()
- Specified by:
getReplayStatisticsString
in interfaceoracle.jdbc.replay.internal.OracleDataSource
-
clearReplayStatistics
public void clearReplayStatistics()
Description copied from interface:OracleDataSource
Clears replay statistics accumulated so far on all connection created by this data source. It is recommended that this call be made when the connections are quiescent and there are few new connections being opened.- Specified by:
clearReplayStatistics
in interfaceOracleDataSource
-
updateReplayStatistics
public void updateReplayStatistics(oracle.jdbc.replay.internal.ReplayStatistics newStats)
- Specified by:
updateReplayStatistics
in interfaceoracle.jdbc.replay.internal.OracleDataSource
-
removeReplayStatistics
public void removeReplayStatistics(oracle.jdbc.replay.internal.ReplayStatistics stats)
- Specified by:
removeReplayStatistics
in interfaceoracle.jdbc.replay.internal.OracleDataSource
-
getSystemProperty
protected static java.lang.String getSystemProperty(java.lang.String property, java.lang.String defaultValue)
-
getRequestSizeLimit
public int getRequestSizeLimit() throws java.sql.SQLException
- Specified by:
getRequestSizeLimit
in interfaceoracle.jdbc.replay.internal.OracleDataSource
- Throws:
java.sql.SQLException
-
getSSSCursorProperty
protected final boolean getSSSCursorProperty() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getProxyFactory
public oracle.jdbc.proxy.ProxyFactory getProxyFactory() throws java.sql.SQLException
- Specified by:
getProxyFactory
in interfaceoracle.jdbc.replay.internal.OracleDataSource
- Throws:
java.sql.SQLException
-
registerMBean
public static void registerMBean()
-
unregisterMBean
public static void unregisterMBean()
-
cleanup
public static void cleanup()
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
getDiagnosable
public oracle.jdbc.diagnostics.Diagnosable getDiagnosable()
AC specifc- Specified by:
getDiagnosable
in interfaceoracle.jdbc.diagnostics.Diagnosable
-
getMonitorLock
public final oracle.jdbc.internal.Monitor.CloseableLock getMonitorLock()
- Specified by:
getMonitorLock
in interfaceoracle.jdbc.internal.Monitor
-
setTokenSupplier
public final void setTokenSupplier(java.util.function.Supplier<? extends AccessToken> tokenSupplier)
Description copied from interface:OracleCommonDataSource
Sets a supplier function that generates an access token when creating a connection with this
DataSource
. The supplier function is invoked each time thisDataSource
creates a connection. Instances ofAccessToken
that 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
DataSource
with both a token supplier and with a user name or password. If invocations ofOracleCommonDataSource.setUser(String)
,OracleCommonDataSource.setPassword(String)
,OracleCommonDataSource.setConnectionProperties(java.util.Properties)
, orOracleCommonDataSource.setConnectionProperty(String, String)
have configured thisDataSource
with a user name or password, and an invocation of this method has also configured a token supplier, then aSQLException
indicating an invalid configuration is thrown when creating a connection with this datasource.Note that
AccessToken.createJsonWebTokenCache(Supplier)
can be called to create a thread safeSupplier
that caches tokens from a user definedSupplier
.- Specified by:
setTokenSupplier
in interfaceOracleCommonDataSource
- Parameters:
tokenSupplier
- Token supplying function. Notnull
.
-
-