Monday, January 19, 2009

3.1 DriverManager Overview

The DriverManager class is the traditional management layer of JDBC, working between the user and the drivers. It keeps track of the drivers that are available and handles establishing a connection between a database and the appropriate driver. In addition, the DriverManager class attends to things like driver login time limits and the printing of log and tracing messages.
Note that the javax.sql package provides the DataSource interface as an alternate and preferred means of connecting to a data source. However, the DriverManager facility can still be used with drivers that support DataSource implementations.
For simple applications, the only method in the DriverManager class that a general programmer needs to use directly is DriverManager.getConnection. As its name implies, this method establishes a connection to a database. An application may call the DriverManager methods getDriver, getDrivers, and registerDriver as well as the Driver method connect, but in most cases it is better to let the DriverManager class manage the details of establishing a connection.

0 Comments: