Internal technique about initialize Connection Interface in JDBC
Rahul Kumar Tiwari
Joined: Jun 09, 2008
In one of the interview faced by me recently, an interviewer asked me Connection Interface of JDBC is a Interface and we cant make the object of interface the how we initialize the object of connection using DriverManager Class like this
Please explain me the answer of the above question...
getConnection — the method the JDBC client invokes to establish a connection.
The invocation includes a JDBC URL, which the DriverManager passes to each
driver in its list until it finds one whose Driver.connect method recognizes the
URL. That driver returns a Connection object to the DriverManager, which in
turn passes it to the application.
DriverManager just passes the URL to each registered driver, if one driver accepts the url, then this driver creates a connection object
(that implements Connection interface) and returns this object to the driver manager.