All Packages Class Hierarchy This Package Previous Next Index
Class oracle.jdbc.pool.OracleDataSource
java.lang.Object
|
+----oracle.jdbc.pool.OracleDataSource
- public class OracleDataSource
- extends Object
- implements Serializable
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.
-
OracleDataSource()
-
-
getConnection()
-
Attempt to establish a database connection.
-
getConnection(String, String)
-
Attempt to establish a database connection.
-
getDatabaseName()
- Get the name of the database set on this DataSource instance.
-
getDataSourceName()
- Get the datasource name for this instance if set.
-
getDescription()
- Get the Desciption of this data source.
-
getDriverType()
- Get the Oracle JDBC driver type set for this datasource instance
-
getLoginTimeout()
- u Gets the maximum time in seconds that this data source can wait
while attempting to connect to a database.
-
getLogWriter()
-
Get the log writer for this data source.
-
getNetworkProtocol()
- Get the network protocol set.
-
getPortNumber()
- Get the port number on which server is listening for requests.
-
getReference()
-
-
getServerName()
- Get the name of the server on which database is running.
-
getTNSEntryName()
- Get the TNS entry name for this instance if set.
-
getURL()
- Get the URL for this datasource.
-
getUser()
- Get the user name for this datasource.
-
setDatabaseName(String)
- Set the name of a particular database on a server.
-
setDataSourceName(String)
- Set the DataSourceName.
-
setDescription(String)
- Set the Desciption for this data source instance.
-
setDriverType(String)
- Set the JDBC driver type.
-
setLoginTimeout(int)
-
Sets the maximum time in seconds that this data source will wait
while attempting to connect to a database.
-
setLogWriter(PrintWriter)
-
Set the log writer for this data source.
-
setNetworkProtocol(String)
- Set the network protocol for the connections.
-
setPassword(String)
- Set the password with which connections have to be obtained.
-
setPortNumber(int)
- Set the port number where a server is listening for requests.
-
setServerName(String)
- Set the name of the Server on which database is running.
-
setTNSEntryName(String)
- Set the TNS entry name.
-
setURL(String)
- Set the URL from which connections have to be obtained.
-
setUser(String)
- Set the user name with which connections have to be obtained.
OracleDataSource
public OracleDataSource() throws SQLException
getConnection
public synchronized Connection getConnection() throws SQLException
-
Attempt to establish a database connection.
- Returns:
- a Connection to the database
- Throws: SQLException
- if a database-access error occurs.
getConnection
public synchronized Connection getConnection(String user,
String passwd) throws SQLException
-
Attempt to establish a database connection.
- Parameters:
- user - the database user on whose behalf the Connection is
being made
- password - the user's password
- Returns:
- a Connection to the database
- Throws: SQLException
- if a database-access error occurs.
getLoginTimeout
public synchronized int getLoginTimeout()
- u 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.
- Returns:
- the data source login time limit
- Throws: SQLException
- if a database access error occurs.
setLoginTimeout
public synchronized 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.
- Parameters:
- seconds - the data source login time limit
- Throws: SQLException
- if a database access error occurs.
setLogWriter
public synchronized void setLogWriter(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.
- Parameters:
- out - the new log writer; to disable, set to null
- Throws: SQLException
- if a database-access error occurs.
getLogWriter
public synchronized 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.
- Returns:
- the log writer for this data source, null if disabled
- Throws: SQLException
- if a database-access error occurs.
setTNSEntryName
public synchronized void setTNSEntryName(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 synchronized String getTNSEntryName()
- Get the TNS entry name for this instance if set. Returns null
if not set.
- Returns:
- TNS entry name
setDataSourceName
public synchronized void setDataSourceName(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.
- Parameters:
- dsname - DataSource Name to be set.
getDataSourceName
public synchronized String getDataSourceName()
- Get the datasource name for this instance if set. Returns null
if not set.
- Returns:
- DaraSource name
getDatabaseName
public synchronized String getDatabaseName()
- Get the name of the database set on this DataSource instance.
- Returns:
- database name set on this instance or null if not set.
setDatabaseName
public synchronized void setDatabaseName(String dsname)
- 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.
- Parameters:
- dsname - database name to be set.
setServerName
public synchronized void setServerName(String sn)
- Set 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.
getServerName
public synchronized String getServerName()
- Get the name of the server on which database is running.
- Returns:
- server name set on this instance or null if not set.
setURL
public synchronized void setURL(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.
- Parameters:
- url - URL to be set.
getURL
public synchronized String getURL() throws SQLException
- Get the URL for this datasource. Will return the default
value "jdbc:oracle:oci8:@" if not set before.
- Returns:
- s URL for this datasource.
setUser
public synchronized void setUser(String user)
- Set the user name with which connections have to be obtained.
- Parameters:
- user - Username to be set.
getUser
public synchronized String getUser()
- Get the user name for this datasource. Will return the default
value ("scott") if not set before.
setPassword
public synchronized void setPassword(String pd)
- Set the password with which connections have to be obtained.
The default value is "tiger".
- Parameters:
- pd - Passowrd to be set.
getDescription
public synchronized String getDescription()
- Get the Desciption of this data source.
- Returns:
- Description that was set or will return null if not set.
setDescription
public synchronized void setDescription(String des)
- Set the Desciption for this data source instance.
- Parameters:
- des - Desciption to be set.
getDriverType
public synchronized 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 synchronized void setDriverType(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 synchronized String getNetworkProtocol()
- Get the network protocol set.
- Returns:
- network protocol that was set or null if not.
setNetworkProtocol
public synchronized void setNetworkProtocol(String np)
- 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.
- Parameters:
- np - set the network protocol to be used.
setPortNumber
public synchronized void setPortNumber(int pn)
- Set 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
getPortNumber
public synchronized int getPortNumber()
- Get the port number on which server is listening for requests.
- Returns:
- port number if set or null if not set.
getReference
public Reference getReference() throws NamingException
All Packages Class Hierarchy This Package Previous Next Index