«Back to Home

Core Java

Topics

DriverManager Class In Java

DriverManager Class
 
In JDBC, the DriverManager class works as an interface between the user and drivers. It keeps a track of the drivers, which are available and handles establishing a connection between a database and the appropriate driver. This class maintains a list of driver classes, which have registered themselves by calling the method DriverManager.registerDriver().
 
Methods of DriverManager class

public static void registerDriver(Driver driver)

This method is used to register the given driver with DriverManager.
 
public static void deregisterDriver(Driver driver)

This method is used to deregister the given driver with DriverManager.
 
public static Connection getConnection(String url)

This method is used to establish the connection with the specified URL.
 
public static Connection getConnection(String url,String userName,String password)

This method is used to establish the connection with the particular URL, username and password.
 
Summary

Thus, we learnt, JDBC DriverManager class works as an interface between the user, drivers and also learn its important methods in Java.