Tuesday 20 December 2016

DriverManager

  The DriverManager class is the 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.

Methods Of DriverManager Class:

1) public static void registerDriver(Driver driver):
is used to register the given driver with DriverManager.
2) public static void deregisterDriver(Driver driver):
is used to deregister the given driver (drop the driver from the list) with DriverManager.
3) public static Connection getConnection(String url):
is used to establish the connection with the specified url.
4) public static Connection getConnection(String url,String userName,String password):
is used to establish the connection with the specified url, username and passw

For simple applications, the only method in this class that a general programmer needs to use directly is DriverManager.getConnection. As its name implies, this method establishes a connection to a database. JDBC allows the user to 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:

Post a Comment

Powered by Blogger.

Stats