aspose file tools
The moose likes JDBC and the fly likes Internal technique about initialize Connection Interface in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Internal technique about initialize Connection Interface in JDBC" Watch "Internal technique about initialize Connection Interface in JDBC" New topic
Author

Internal technique about initialize Connection Interface in JDBC

Rahul Kumar Tiwari
Greenhorn

Joined: Jun 09, 2008
Posts: 14
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
Ex:-


Please explain me the answer of the above question...
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Hi,

we can't make an object of an interface, but we can create an object of a class that implements this interface.
You can find an explanation how DriverManager.getConnection works in the JDBC specyfication:
http://jcp.org/aboutJava/communityprocess/final/jsr221/index.html
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.

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Internal technique about initialize Connection Interface in JDBC
 
Similar Threads
Connection is interface so how can we access it createStatement() on connection objec
JDBC Connection Interface
how to make JDBC connection
What is meant by LOADING DRIVER CLASS and RIGESTERING DRIVER CLASS
what happens if two drivers are loaded?