The Connection object represents a connection to a data source in Java™ Database Connectivity (JDBC). It is through Connection objects that Statement objects are created for processing SQL statements against the database. An application program can have multiple connections at one time. These Connection objects can all connect to the same database or connect to different databases.
Obtaining a connection in JDBC can be accomplished in two ways:
Using DataSources to obtain a connection is preferred because it enhances application portability and maintainability. It also allows an application to transparently use connection and statement pooling, and distributed transactions.
For details on obtaining connections, see the following sections:
DriverManager The DriverManager is a static class that manages the set of available JDBC drivers for an application to use.
Connection properties The table lists valid JDBC driver connection properties, their values, and their descriptions.
Use DataSources with UDBDataSource You can deploy a DataSource with the UDBDataSource class by setting it up to have specific properties and then binding it into some directory service through the use of the Java Naming and Directory Interface (JNDI).
DataSource properties The table lists valid DataSource properties, their values, and their descriptions.
Other DataSource implementations There are other implementations of the DataSource interface provided with the native JDBC driver. They exist only to serve as a bridge until the UDBDataSource and its related functions are adopted.
Once a connection is obtained, it can be used to accomplish the following JDBC tasks: