Save This Page
Home » apache-harmony-6.0-src-r917296-snapshot » javax » sql » [javadoc | source]
javax.sql
public interface: DataSource [javadoc | source]

All Implemented Interfaces:
    CommonDataSource, Wrapper

An interface for the creation of {@code Connection} objects which represent a connection to a database. This interface is an alternative to the {@code java.sql.DriverManager}.

A class which implements the {@code DataSource} interface is typically registered with a JNDI naming service directory and is retrieved from there by name.

The {@code DataSource} interface is typically implemented by the writer of a JDBC driver. There are three variants of the {@code DataSource} interface, which produce connections with different characteristics:

  1. Standard {@code DataSource}: produces standard {@code Connection} objects with no special features.
  2. Connection Pool {@code DataSource}: produces {@code PooledConnection} objects which require a connection pool manager as an intermediary component.
  3. Distributed transaction {@code DataSource} ("XADataSource"): produces {@code XAConnection} objects which can be used to handle distributed transactions which typically require an intermediary transaction manager component. {@code XAConnection} objects also provide connection pooling capabilities as well as distributed transaction capabilities.

Note that a JDBC driver which is accessed via the {@code DataSource} interface is loaded via a JNDI lookup process. A driver loaded in this way does not register itself with the {@code DriverManager}.
Method from javax.sql.DataSource Summary:
getConnection,   getConnection
Method from javax.sql.DataSource Detail:
 public Connection getConnection() throws SQLException
    Creates a connection to the database represented by this {@code DataSource}.
 public Connection getConnection(String theUsername,
    String thePassword) throws SQLException
    Creates a connection to the database represented by this {@code DataSource}, using the supplied user name and password.