Driver interface in java

Driver interface

 From this place a connection to the database is made.
 This enables a DriverManager class.
 DriverManager is a class which belongs to java.sql package & this communicates with the driver using URL(Universal Resource Locator)

DriverManager class

 This class is used to manage JDBC drivers which are installed on our system.
 To load JDBC drivers
Driver d = (Driver)class.forName(drivername).
newInstance();
 The DriverManager controls the interaction between user interface & database driver
 The Driver Manager can perform the following
 Locate a driver for a particular database
 Process JDBC initialization calls
 Provide entry points to JDBC function for each specific driver
 Perform parameter & sequence validation for JDBC calls

DriverManager Methods

 deregisterDriver()
This is used to remove driver object from the current list
 getConnection(String url)
It assumes that there is no user name, password or any other database property which is needed for connection
 getConnection(String url, Property argument)
It takes url & properties object which contains database properties which are needed for connection
 getConnection(Sting url,String userid,String password)
It provides user name & password with url. The username identifies the user & his password & then only get connection
 getDriver()
Allows to get drivers which are regitered. This method returns a Driver object.
 getDrivers()
It allows us to get arrays of driver object which are currently registered

Leave a Reply

Your email address will not be published. Required fields are marked *