File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Calling a method on Connection interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Calling a method on Connection interface" Watch "Calling a method on Connection interface" New topic

Calling a method on Connection interface

Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
Hi Friends,
I have a small query worth mentioning in this forumn.

We all know Connection (java.sql) is an interface. Then how can we call a method like close() on an interface reference. I mean where are these methods being referred from..Any1 knowing the reason for the same kindly help me...

Thanks & Regards,

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

We can do this because we are actually calling a method against the interface implementation not the interface direct. The implementation of the Connection interface is part of the JDBC driver you are using.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Calling a method on Connection interface
Similar Threads
Please explain my problem
Connection pooling &
Where is Connection interface implemented
Java Class Implementation Logic
which concrete class has the implementation for createStatement method