by Dinesh Thakur

The DriverManager class is responsible for loading the driver specific classes. The drivers are registered with the DriverManager class either when an instance of driver is created using registerDriver (Driver driver) method of the DriverManager class or DriverManager class is initialized.

The static method forName () of the Class class can be used by DriverManager class to locate and load the drivers listed in system variable jdbc.drivers is as follows.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver")

Here, the driver class specified in the string parameter is loaded dynamically at the run time.

Some of the methods of the DriverManager are as follows.

Connection getConnection (String url): This method attempts to establish a connection to a given database URL--does not require password.

Connection getConnection(String url, String user, String password): This method attempts to establish a connection to a given database URL.

void registerDriver (Driver driver): This method is used to register a driver specified by driver with the DriverManager.

void deregisterDriver (Driver driver): This method removes the driver specified by driver from the DriverManager's list.