This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Object of Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Object of Interfaces" Watch "Object of Interfaces" New topic
Author

Object of Interfaces

Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
Hi Ranchers

As we know we can't make objects of interfaces.But while writing JDBC codes the getConnection() method returns Connection object...How?
Please clarify this
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

It returns an object that implements Connection.

Regards, Jan


OCUP UML fundamental
ITIL foundation
Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
Jan Cumps wrote:It returns an object that implements Connection.

Regards, Jan



Thanks for replying Jan
You mean to say that there is some anonymous class that implements it?
Kiran Joshi
Ranch Hand

Joined: Sep 04, 2005
Posts: 54
The implementing class is not required to be anonymous.
It is provided through the jars you keep in your classpath.
for example ojdbc14.jar or classes12.jar provided by db vendors like (oracle) or third parties that provide jdbc drivers.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26184
    
  66

Right. The interface is so you don't refer to the concrete class. That way you can change databases/drivers without changing your code.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object of Interfaces
 
Similar Threads
down-casting a class
interface reference
obj conversion
Inner class Vs Outer Class
Sending wsdl DateTime from java client