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.


Constructor Index

 o OracleDataSource()

Method Index

 o getConnection()

Attempt to establish a database connection.

 o getConnection(String, String)

Attempt to establish a database connection.

 o getDatabaseName()
Get the name of the database set on this DataSource instance.
 o getDataSourceName()
Get the datasource name for this instance if set.
 o getDescription()
Get the Desciption of this data source.
 o getDriverType()
Get the Oracle JDBC driver type set for this datasource instance
 o getLoginTimeout()
u Gets the maximum time in seconds that this data source can wait while attempting to connect to a database.
 o getLogWriter()

Get the log writer for this data source.

 o getNetworkProtocol()
Get the network protocol set.
 o getPortNumber()
Get the port number on which server is listening for requests.
 o getReference()
 o getServerName()
Get the name of the server on which database is running.
 o getTNSEntryName()
Get the TNS entry name for this instance if set.
 o getURL()
Get the URL for this datasource.
 o getUser()
Get the user name for this datasource.
 o setDatabaseName(String)
Set the name of a particular database on a server.
 o setDataSourceName(String)
Set the DataSourceName.
 o setDescription(String)
Set the Desciption for this data source instance.
 o setDriverType(String)
Set the JDBC driver type.
 o setLoginTimeout(int)

Sets the maximum time in seconds that this data source will wait while attempting to connect to a database.

 o setLogWriter(PrintWriter)

Set the log writer for this data source.

 o setNetworkProtocol(String)
Set the network protocol for the connections.
 o setPassword(String)
Set the password with which connections have to be obtained.
 o setPortNumber(int)
Set the port number where a server is listening for requests.
 o setServerName(String)
Set the name of the Server on which database is running.
 o setTNSEntryName(String)
Set the TNS entry name.
 o setURL(String)
Set the URL from which connections have to be obtained.
 o setUser(String)
Set the user name with which connections have to be obtained.

Constructors

 o OracleDataSource
 public OracleDataSource() throws SQLException

Methods

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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
 o getTNSEntryName
 public synchronized String getTNSEntryName()
Get the TNS entry name for this instance if set. Returns null if not set.

Returns:
TNS entry name
 o 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.
 o getDataSourceName
 public synchronized String getDataSourceName()
Get the datasource name for this instance if set. Returns null if not set.

Returns:
DaraSource name
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o setUser
 public synchronized void setUser(String user)
Set the user name with which connections have to be obtained.

Parameters:
user - Username to be set.
 o getUser
 public synchronized String getUser()
Get the user name for this datasource. Will return the default value ("scott") if not set before.

 o 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.
 o getDescription
 public synchronized String getDescription()
Get the Desciption of this data source.

Returns:
Description that was set or will return null if not set.
 o setDescription
 public synchronized void setDescription(String des)
Set the Desciption for this data source instance.

Parameters:
des - Desciption to be set.
 o 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.
 o 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.
 o getNetworkProtocol
 public synchronized String getNetworkProtocol()
Get the network protocol set.

Returns:
network protocol that was set or null if not.
 o 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.
 o 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
 o 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.
 o getReference
 public Reference getReference() throws NamingException

All Packages  Class Hierarchy  This Package  Previous  Next  Index