A factory for connections to the physical data source that this
DataSource object represents. An alternative to the
DriverManager facility, a DataSource object
is the preferred means of getting a connection. An object that implements
the DataSource interface will typically be
registered with a naming service based on the
Java™ Naming and Directory (JNDI) API.
The DataSource interface is implemented by a driver vendor.
There are three types of implementations:
Connection
object
Connection
object that will automatically participate in connection pooling. This
implementation works with a middle-tier connection pooling manager.
Connection object that may be used for distributed
transactions and almost always participates in connection pooling.
This implementation works with a middle-tier
transaction manager and almost always with a connection
pooling manager.
A DataSource object has properties that can be modified
when necessary. For example, if the data source is moved to a different
server, the property for the server can be changed. The benefit is that
because the data source's properties can be changed, any code accessing
that data source does not need to be changed.
A driver that is accessed via a DataSource object does not
register itself with the DriverManager. Rather, a
DataSource object is retrieved though a lookup operation
and then used to create a Connection object. With a basic
implementation, the connection obtained through a DataSource
object is identical to a connection obtained through the
DriverManager facility.
HSQLDB-Specific Information:
This implementation of data source is a basic implementation and does not perform connection pooling.
The getter and setter methods of the parent class, JDBCCommonDataSource,
can be used.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Connection | Returns: a connection to the data sourceImplements javax. Retrieves a new connection using the properties that have already been set. |
| public Connection | Returns: a connection to the data sourcethe database user on whose behalf the connection is
being made username, String the user's password password)Implements javax. Retrieves a new connection using the given username and password, and the database url that has been set. |
| private Connection | |
| public Reference | Returns: The non-null Reference of this object.Implements javax. Retrieves the Reference of this object. |
| public boolean | Returns: true if this implements the interface or directly or indirectly wraps an object that does.a Class defining an interface. iface)Implements java. Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. |
| public <T> T | Returns: an object that implements the interface. May be a proxy for the actual implementing object.A Class defining an interface that the result must implement. iface)Implements java. Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. |
| JDBCDataSource | back to summary |
|---|---|
| public JDBCDataSource() | |
| getConnection | back to summary |
|---|---|
| public Connection getConnection() throws SQLException Implements javax. Retrieves a new connection using the properties that have already been set.
| |
| getConnection | back to summary |
|---|---|
| public Connection getConnection(String username, String password) throws SQLException Implements javax. Retrieves a new connection using the given username and password, and the database url that has been set. No other properties are used for the connection
| |
| getConnection | back to summary |
|---|---|
| private Connection getConnection(String url, Properties props) throws SQLException | |
| getReference | back to summary |
|---|---|
| public Reference getReference() throws NamingException Implements javax. Retrieves the Reference of this object.
| |
| isWrapperFor | back to summary |
|---|---|
| public boolean isWrapperFor(Class<?> iface) throws SQLException Implements java. Returns true if this either implements the interface argument or is directly or indirectly a wrapper
for an object that does. Returns false otherwise. If this implements the interface then return true,
else if this is a wrapper then return the result of recursively calling
| |
| unwrap | back to summary |
|---|---|
| public <T> T unwrap(Class<T> iface) throws SQLException Implements java. Returns an object that implements the given interface to allow access to
non-standard methods, or standard methods not exposed by the proxy.
If the receiver implements the interface then the result is the receiver
or a proxy for the receiver. If the receiver is a wrapper
and the wrapped object implements the interface then the result is the
wrapped object or a proxy for the wrapped object. Otherwise return
the result of calling
| |