• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC-interfaces

 
Vinny Menon
Ranch Hand
Posts: 62
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mani Ram
Ranch Hand
Posts: 1140
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic