javax.sql.DataSource |
An interface for the creation of Connection
objects which represent a
connection to a database. This interface is an alternative to the java.sql.DriverManager
.
A class which implements the DataSource
interface is typically
registered with a JNDI naming service directory and is retrieved from there
by name.
The DataSource
interface is typically implemented by the writer of a
JDBC driver. There are three variants of the DataSource
interface,
which produce connections with different characteristics:
DataSource
: produces standard Connection
objects with no special features.DataSource
: produces PooledConnection
objects which require a connection pool manager as an
intermediary component.DataSource
("XADataSource"):
produces XAConnection
objects which can be used to handle distributed
transactions which typically require an intermediary transaction manager
component. XAConnection
objects also provide connection pooling
capabilities as well as distributed transaction capabilities.
Note that a JDBC driver which is accessed via the DataSource
interface is loaded via a JNDI lookup process. A driver loaded in this way
does not register itself with the DriverManager
.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a connection to the database represented by this
DataSource , using the supplied user name and password. | |||||||||||
Creates a connection to the database represented by this
DataSource . | |||||||||||
Gets the log writer for this
DataSource . | |||||||||||
Gets the login timeout value for this
DataSource . | |||||||||||
Sets the log writer for this
DataSource . | |||||||||||
Sets the login timeout value for this
DataSource . |
Creates a connection to the database represented by this DataSource
, using the supplied user name and password.
theUsername | the a user name for the database login. |
---|---|
thePassword | the password associated with the user identified by theUsername . |
Connection
object which is the connection to the
database.SQLException | if there is a problem accessing the database. |
---|
Creates a connection to the database represented by this DataSource
.
Connection
object which is a connection to the
database.SQLException | if there is a problem accessing the database. |
---|
Gets the log writer for this DataSource
.
The log writer is a stream to which all log and trace messages are sent
from this DataSource
. The log writer can be null
, in
which case, log and trace capture is disabled. The default value for the
log writer when an DataSource
is created is null
. Note
that the log writer for a DataSource
is not the same as the log
writer used by a DriverManager
.
PrintWriter
which is the log writer for this DataSource
. Can be null
, in which case log writing is
disabled for this DataSource
.SQLException | if there is a problem accessing the database. |
---|
Gets the login timeout value for this DataSource
. The login
timeout is the maximum time in seconds that the DataSource
will
wait when opening a connection to a database. A timeout value of 0
implies either the system default timeout value (if there is one) or that
there is no timeout. The default value for the login timeout is 0.
SQLException | if there is a problem accessing the database. |
---|
Sets the log writer for this DataSource
.
The log writer is a stream to which all log and trace messages are sent
from this DataSource
. The log writer can be null
, in
which case, log and trace capture is disabled. The default value for the
log writer when a DataSource
is created is null
. Note
that the log writer for a DataSource
is not the same as the log
writer used by a DriverManager
.
theWriter | a PrintWriter to use as the log writer for this
DataSource . |
---|
SQLException | if there is a problem accessing the database. |
---|
Sets the login timeout value for this DataSource
. The login
timeout is the maximum time in seconds that the DataSource
will
wait when opening a connection to a database. A timeout value of 0
implies either the system default timeout value (if there is one) or that
there is no timeout. The default value for the login timeout is 0.
theTimeout | the new login timeout value in seconds. |
---|
SQLException | if there is a problem accessing the database. |
---|