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
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
posted 10 years ago
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.