|
Oracle JDBC API Reference 11g Release 2 ("11.2.0.3.0") |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object oracle.jdbc.pool.OracleDataSource
public class OracleDataSource
A DataSource object is a factory for Connection objects. An object that implements the DataSource interface will typically be registered with a JNDI service provider. A JDBC driver that is accessed via the DataSource API does not automatically register itself with the DriverManager.
Field Summary | |
---|---|
static java.lang.String |
BUILD_DATE
|
boolean |
isOracleDataSource
|
static boolean |
TRACE
|
Constructor Summary | |
---|---|
OracleDataSource()
|
Method Summary | |
---|---|
void |
close()
Deprecated. Use Oracle Universal Connection Pool instead. Close DataSource API. This removes the associated Connection Cache and frees resources. This must be the last method to invoke, after the user is finished using a cache enabled DataSource. |
java.sql.Connection |
getConnection()
Attempt to establish a database connection. |
java.sql.Connection |
getConnection(java.util.Properties cachedConnectionAttributes)
Deprecated. Use Oracle Universal Connection Pool instead. Attempt to obtain a database connection from the Implicit Connection Cache using Connection Attributes |
java.sql.Connection |
getConnection(java.lang.String _user,
java.lang.String _passwd)
Attempt to establish a database connection. |
java.sql.Connection |
getConnection(java.lang.String _user,
java.lang.String _passwd,
java.util.Properties cachedConnectionAttributes)
Deprecated. Use Oracle Universal Connection Pool instead. Attempt to obtain a database connection from the Implicit Connection Cache using user, passwd and Connection Attributes |
java.lang.String |
getConnectionCacheName()
|
java.util.Properties |
getConnectionCacheProperties()
|
boolean |
getConnectionCachingEnabled()
|
java.util.Properties |
getConnectionProperties()
getConnectionProperties Returns the current Properties set in the datasource. |
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. |
java.lang.String |
getDriverType()
Get the Oracle JDBC driver type set for this datasource instance |
boolean |
getExplicitCachingEnabled()
getExplicitCachingEnabled Returns the current value of the explicitCachingEnabled property. |
boolean |
getFastConnectionFailoverEnabled()
|
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. |
java.lang.String |
getNetworkProtocol()
Get the network protocol set. |
java.lang.String |
getONSConfiguration()
Deprecated. Use Oracle Universal Connection Pool instead. Return the ONS configuration string that is used for remote ONS subscription, in the form specified in setONSConfiguration(String). This is used by Fast Connection Failover and Runtime Load Balancing. |
int |
getPortNumber()
Get the port number on which server is listening for requests. |
javax.naming.Reference |
getReference()
|
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. |
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. |
void |
setConnectionCacheName(java.lang.String cacheName)
|
void |
setConnectionCacheProperties(java.util.Properties cp)
Deprecated. Use Oracle Universal Connection Pool instead. Setter method to set one or more Implicit Connection Cache properties. If a null value is set, default values will take effect. Below are the list of properties supported. These are the keys (case sensitive) to be used when setting their appropriate values. |
void |
setConnectionCachingEnabled(boolean flag)
Deprecated. Use Oracle Universal Connection Pool instead. Setter method to enable Implicit Connection Caching |
void |
setConnectionProperties(java.util.Properties value)
Sets the Connection Properties for the datasource |
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 |
setFastConnectionFailoverEnabled(boolean flag)
|
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 |
setONSConfiguration(java.lang.String onsConfigStr)
Deprecated. Use Oracle Universal Connection Pool instead. Set the configuration string used for remote ONS subscription.
The parameter string closely resembles the content of the ONS
configuration file "ons.config", and contains a list of " An example ONS configuration string:
This is used primarily by Fast Connection Failover and Runtime Load Balancing. |
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 |
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 |
setTNSEntryName(java.lang.String dbname)
Set the TNS entry name. |
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. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean isOracleDataSource
public static final java.lang.String BUILD_DATE
public static final boolean TRACE
Constructor Detail |
---|
public OracleDataSource() throws java.sql.SQLException
java.sql.SQLException
Method Detail |
---|
public java.sql.Connection getConnection() throws java.sql.SQLException
Attempt to establish a database connection.
getConnection
in interface javax.sql.DataSource
java.sql.SQLException
- if a database-access error occurs.public java.sql.Connection getConnection(java.lang.String _user, java.lang.String _passwd) throws java.sql.SQLException
Attempt to establish a database connection.
getConnection
in interface javax.sql.DataSource
user
- the database user on whose behalf the Connection is
being madepassword
- the user's password
java.sql.SQLException
- if a database-access error occurs.public java.sql.Connection getConnection(java.util.Properties cachedConnectionAttributes) throws java.sql.SQLException
Attempt to obtain a database connection from the Implicit Connection Cache using Connection Attributes
java.sql.SQLException
- if a database-access error occurs.public java.sql.Connection getConnection(java.lang.String _user, java.lang.String _passwd, java.util.Properties cachedConnectionAttributes) throws java.sql.SQLException
Attempt to obtain a database connection from the Implicit Connection Cache using user, passwd and Connection Attributes
java.sql.SQLException
- if a database-access error occurs.public void close() throws java.sql.SQLException
Close DataSource API. This removes the associated Connection Cache and frees resources. This must be the last method to invoke, after the user is finished using a cache enabled DataSource.
java.sql.SQLException
public void setConnectionCachingEnabled(boolean flag) throws java.sql.SQLException
Setter method to enable Implicit Connection Caching
flag
- boolean value
java.sql.SQLException
public boolean getConnectionCachingEnabled() throws java.sql.SQLException
java.sql.SQLException
public void setConnectionCacheName(java.lang.String cacheName) throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getConnectionCacheName() throws java.sql.SQLException
java.sql.SQLException
public void setConnectionCacheProperties(java.util.Properties cp) throws java.sql.SQLException
Setter method to set one or more Implicit Connection Cache properties. If a null value is set, default values will take effect. Below are the list of properties supported. These are the keys (case sensitive) to be used when setting their appropriate values.
cp
- key/value pairs. Description of the supported keys follow.
Sets limit on Minimum number of connections. Defaults to 0.
Sets limit on Maximum number of connections. No default.
Sets limit on the number of initial connections populated, when the cache is first created. Defaults to 0.
Sets the Maximum number of statements that each connection keeps open, for statement caching. Defaults to 0.
Sets the Maximum time, in seconds, a connection in the cache can remain idle (that is not checked out of the cache). Defaults to 0.
Sets that maximum time, in seconds, a checked out connection can remain idle. Defaults to 0.
Sets the maximum time a checked out connection can remain unused (no SQL activity) before the connection is closed and returned to the cache. Defaults to 0.
Specifies the time limit to wait, when a new connection request arrives, and there are no connections to check out. Defaults to 0.
Sets the time interval for the cache daemon thread to enforce the time out limits. Defaults to 900 seconds (15 minutes).
Verifies each connection for validity, before a checked out connection is returned to the caller. Defaults to false.
Causes the connection cache to retrieve the connection with the closest approximation to the specified connection attributes. Defaults to false.
Sets the weight (integer) for each connection attribute. This is used when ClosestConnectionMatch is set to true, and enables retrieval of a connection with the highest combined weight of all its connection attributes. Defaults to a weight of 1.
Sets the lower threshold limit on the cache. This is used for the releaseConnection() cache callback method is registered. Defaults to 20%.
java.sql.SQLException
public java.util.Properties getConnectionCacheProperties() throws java.sql.SQLException
java.sql.SQLException
public void setFastConnectionFailoverEnabled(boolean flag) throws java.sql.SQLException
java.sql.SQLException
public boolean getFastConnectionFailoverEnabled() throws java.sql.SQLException
java.sql.SQLException
public java.lang.String getONSConfiguration() throws java.sql.SQLException
Return the ONS configuration string that is used for remote ONS subscription, in the form specified in setONSConfiguration(String). This is used by Fast Connection Failover and Runtime Load Balancing.
java.sql.SQLException
public void setONSConfiguration(java.lang.String onsConfigStr) throws java.sql.SQLException
Set the configuration string used for remote ONS subscription.
The parameter string closely resembles the content of the ONS
configuration file "ons.config", and contains a list of "
An example ONS configuration string:
"nodes=host1:4200,host2:4200\nwalletfile=wfile\nwalletpassword=wpwd"
This is used primarily by Fast Connection Failover and Runtime Load Balancing.
onsConfigStr
- The configuration string for remote ONS subscription
java.sql.SQLException
public int getLoginTimeout()
getLoginTimeout
in interface javax.sql.DataSource
java.sql.SQLException
- if a database access error occurs.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.
setLoginTimeout
in interface javax.sql.DataSource
seconds
- the data source login time limit
java.sql.SQLException
- if a database access error occurs.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.
setLogWriter
in interface javax.sql.DataSource
out
- the new log writer; to disable, set to null
java.sql.SQLException
- if a database-access error occurs.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.
getLogWriter
in interface javax.sql.DataSource
java.sql.SQLException
- if a database-access error occurs.public void setTNSEntryName(java.lang.String dbname)
dbname
- tns entry namepublic java.lang.String getTNSEntryName()
public void setDataSourceName(java.lang.String dsname)
dsname
- DataSource Name to be set.public java.lang.String getDataSourceName()
public java.lang.String getDatabaseName()
public void setDatabaseName(java.lang.String dbname)
If URL is set, this property will be ignored.
dsname
- database name to be set.public void setServiceName(java.lang.String svcname)
svcname
- service_name to be set.public java.lang.String getServiceName()
public void setServerName(java.lang.String sn)
sn
- server/host name to be set.public java.lang.String getServerName()
public void setURL(java.lang.String url)
url
- URL to be set.public java.lang.String getURL() throws java.sql.SQLException
java.sql.SQLException
public void setUser(java.lang.String userName)
user
- Username to be set.public java.lang.String getUser()
public void setPassword(java.lang.String pd)
pd
- Passowrd to be set.public java.lang.String getDescription()
public void setDescription(java.lang.String des)
des
- Desciption to be set.public java.lang.String getDriverType()
public void setDriverType(java.lang.String dt)
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.
dt
- Driver Type tp be set.public java.lang.String getNetworkProtocol()
public void setNetworkProtocol(java.lang.String np)
np
- set the network protocol to be used.public void setPortNumber(int pn)
pn
- port number on which server is listeningpublic int getPortNumber()
public javax.naming.Reference getReference() throws javax.naming.NamingException
getReference
in interface javax.naming.Referenceable
javax.naming.NamingException
public void setMaxStatements(int max) throws java.sql.SQLException
max
- Requested size of the cache. If the existing cache size
is less than max, statements will be purged to reduce the
size.
java.sql.SQLException
- if max < 0public int getMaxStatements() throws java.sql.SQLException
java.sql.SQLException
public void setImplicitCachingEnabled(boolean cache) throws java.sql.SQLException
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.
java.sql.SQLException
public boolean getImplicitCachingEnabled() throws java.sql.SQLException
java.sql.SQLException
public void setExplicitCachingEnabled(boolean cache) throws java.sql.SQLException
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.
java.sql.SQLException
- if called on a logical connection.public boolean getExplicitCachingEnabled() throws java.sql.SQLException
java.sql.SQLException
public void setConnectionProperties(java.util.Properties value) throws java.sql.SQLException
The argument to this method is a Properties object. This properties object is used to create the connections returned by the receiver. The keys, values, and their meanings are given in the following table. The values are all Strings.The table indicates how the String values are interpreted.
Key | Value | Comment |
user | String | The value of this property is used as the user name when connecting to the database. |
password | String | The value of this property is used as the password when connecting to the database. |
database | String | The value of this property is used as the SID of the database. |
server | String | The value of this property is used as the host name of the database. |
internal_logon | String | The value of this property is used as the user name when performing an internal logon. Usually this will be SYS or SYSDBA. |
defaultRowPrefetch | int | The value of this property is used as the default number of rows to prefetch. |
defaultExecuteBatch | int | The value of this property is used as the default batch size when using Oracle style batching. |
processEscapes | boolean | If the value of this property is "false" then the default setting for Statement.setEscapeProccessing is false. |
disableDefineColumnType | boolean | When this connection property has the value true, the method defineColumnType is has no effect. This is highly recommended when using the Thin driver, especially when the database character set contains four byte characters that expand to two UCS2 surrogate characters, e.g. AL32UTF8. The method defineColumnType provides no performance benefit (or any other benefit) when used with the 10g Thin driver. This property is provided so that you do not have to remove the calls from your code. This is especially valuable if you use the same code with Thin driver and either the OCI or Server Internal driver. |
DMSName | String | Set the name of the DMS Noun that is the parent of all JDBC DMS metrics. |
DMSType | String | Set the type of the DMS Noun that is the parent of all JDBC DMS metrics. |
AccumulateBatchResult | boolean | When using Oracle style batching, JDBC determines when to flush a batch to the database. If this property is true, then the number of modified rows accumulated across all batches flushed from a single statement. The default is to count each batch separately. |
oracle.jdbc.J2EE13Compliant | boolean | If the value of this property is "true", JDBC uses strict compliance for some edge cases. In general Oracle's JDBC drivers will allow some operations that are not permitted in the strict interpretation of J2EE 1.3. Setting this property to true will cause those cases to throw SQLExceptions. There are some other edge cases where Oracle's JDBC drivers have slightly different behavior than defined in J2EE 1.3. This results from Oracle having defined the behavior prior to the J2EE 1.3 specification and the resultant need for compatibility with existing customer code. Setting this property will result in full J2EE 1.3 compliance at the cost of incompatibility with some customer code. Can be either a system property or a connection property. |
oracle.jdbc.TcpNoDelay | boolean | If the value of this property is "true", the TCP_NODELAY property is set on the socket when using the Thin driver. See java.net.SocketOptions.TCP_NODELAY. Can be either a system property or a connection property. |
defaultNChar | boolean | If the value of this property is "true", the default mode for all character data columns will be NCHAR. |
useFetchSizeWithLongColumn | boolean | If the value of this property is "true", then JDBC will prefetch rows even though there is a LONG or LONG RAW column in the result. By default JDBC fetches only one row at a time if there are LONG or LONG RAW columns in the result. Setting this property to true can improve performance but can also cause SQLExceptions if the results are too big. |
remarksReporting | boolean | If the value of this property is "true", OracleDatabaseMetaData will include remarks in the meta data. This can result in a substantial reduction in performance. |
includeSynonyms | boolean | If the value of this property is "true", JDBC will include synonyms when getting information about a column. |
restrictGetTables | boolean | If the value of this property is "true", JDBC will return a more refined value for DatabaseMeta.getTables. By default JDBC will return things that are not accessible tables. These can be non-table objects or accessible synonymns for inaccessible tables. If this property is true JDBC will return only accessible tables. This has a substantial performance penalty. |
fixedString | boolean | If the value of this property is "true", JDBC will use FIXED CHAR semantic when setObject is called with a String argument. By default JDBC uses VARCHAR semantics. The difference is in blank padding. With the default there is no blank padding so, for example, 'a' does not equal 'a ' in a CHAR(4). If true these two will be equal. |
oracle.jdbc.ocinativelibrary | String | Set the name of the native library for the oci driver. If not set, the default name, libocijdbcX (X is a version number), is used. |
oracle.jdbc.StreamBufferSize | int | Set size of the buffer for the InputStream/Reader obtained from getXXXStream/getXXXReader. The default size is 16k. The size passed should be at least 4096 or else 4096 is assumed. |
OCINewPassword | String | Pass the value of new password to be set during logon. This could be typically used for resetting the password when the password has expired or when the account is in the grace period. |
oracle.jdbc.RetainV9BehaviorForLongBind | boolean | This is applicable only for the thin driver. Pass true to retain the V9 bind behavior for Long
and potential long binds.false is the default behavior which would emulate the same
behavior as in OCI driver.
|
oracle.jdbc.FreeMemoryOnEnterImplicitCache | boolean | Clear the define buffers before caching the statement when Implicit
statement caching is enabled. Setting the value to true would enable the clearing of define
buffers before caching of Statements in the Statement cache.
false is the default value and this would behave in the same
way as statement caching worked in prior releases. |
oracle.jdbc.ReadTimeout | int | read timeout while reading from the socket. This affects thin driver
only. Timeout is in milliseconds. |
java.sql.SQLException
public java.util.Properties getConnectionProperties() throws java.sql.SQLException
java.sql.SQLException
|
Oracle JDBC API Reference 11g Release 2 ("11.2.0.3.0") |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |