


A DataSource implementation that supports connection pooling produces Connection objects that participate in connection pooling, that is, connections that can be recycled.A basic DataSource implementation produces standard Connection objects that are not pooled or used in a distributed transaction.It can be implemented in three different ways: The DataSource interface is implemented by a driver vendor. If a company uses more than one data source, it will deploy a separate DataSource object for each of them. A DataSource object represents a particular DBMS or some other data source, such as a file. Objects instantiated by classes that implement the DataSource represent a particular DBMS or some other data source, such as a file. This section shows you how to use a DataSource object to get a connection to your data source, which is the preferred way. In Establishing a Connection, you learned how to get a connection using the DriverManager class. Using DataSource Objects to Get a Connection Using Connections for Distributed Transactions.Deploying Other DataSource Implementations.Using DataSource Objects to Get Connections.As a result, most of this section is devoted to showing how a system administrator sets up the environment so that programmers can use a DataSource object to get connections.

The work performed to deploy the classes that make these operations possible, which a system administrator usually does with a tool (such as Apache Tomcat or Oracle WebLogic Server), varies with the type of DataSource object that is being deployed. Both of these involve very few code changes in your JDBC application. This section shows you how to get a connection using the DataSource interface and how to use distributed transactions and connection pooling. In particular, it is integral to Enterprise JavaBeans (EJB) technology. This functionality is essential for enterprise database computing. In addition to their other advantages, which will be explained later, DataSource objects can provide connection pooling and distributed transactions.

This section covers DataSource objects, which are the preferred means of getting a connection to a data source.
