File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes JDBC-interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "JDBC-interfaces" Watch "JDBC-interfaces" New topic


Vinny Menon
Ranch Hand

Joined: Jan 10, 2006
Posts: 62

The API provided by Java for JDBC contains a class called DriverManager,where as the Connection,Statement,ResultSet are all interfaces.
We know that we cannot instantiate interfaces.
So what really happens when we say e.g.
Connection conn= DriverManager.getConnection();
Is a implicit object of connection created?
Could anybody shed some light on this?
Thanks for your replies.

vinny m

Regards,Vinny M.
proud Fan of European Champion CHELSEA FC
"If you don't see the bug where you're looking, perhaps you're looking in the wrong place" -James Gosling
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
The DriverManager.getConnection(); returns a connection object, which implements the Connection interface. You can see the actual implementation of the connection object in the database driver (ojdbc14.jar or classes12.jar for example, if you are using Oracle).

So, if I'm providing a database driver for my database, I can provide a class like

So, what you get by calling getConnection is nothing but an object of MyConnection class.

Hope that helps.

Quaerendo Invenietis
I agree. Here's the link:
subject: JDBC-interfaces
It's not a secret anymore!