aspose file tools*
The moose likes JDBC and the fly likes JDBC-interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC-interfaces" Watch "JDBC-interfaces" New topic
Author

JDBC-interfaces

Vinny Menon
Ranch Hand

Joined: Jan 10, 2006
Posts: 62

Hi
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.


Mani
Quaerendo Invenietis
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JDBC-interfaces