aspose file tools*
The moose likes Java in General and the fly likes which concrete class has the implementation for createStatement method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "which concrete class has the implementation for createStatement method" Watch "which concrete class has the implementation for createStatement method" New topic
Author

which concrete class has the implementation for createStatement method

sudheer kiran
Ranch Hand

Joined: Jun 26, 2008
Posts: 237



where is the implementation of createStatement method.
Connection is also an interface.
DriverManager returns a Connection Object.but how do we know Which concrete connection object that is


Sudheer
SCWCD, SCJP 5
Ulrika Tingle
Ranch Hand

Joined: Nov 24, 2009
Posts: 92
sudheer kiran wrote:but how do we know Which concrete connection object that is


The idea is that you don't need to know and that makes your code more general and flexible.

Connection and Statement are interfaces. When you write your code using variables of an interface your code will work with any object implementing that interface. Otherwise your code would be tied down to work with objects of one concrete class only.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14342
    
  22

sudheer kiran wrote:DriverManager returns a Connection Object.but how do we know Which concrete connection object that is

That depends on the JDBC driver that you are using - it's a class that the JDBC driver provides. You're not supposed to know in your Java application, because you don't want to make your application dependent on one specific JDBC driver. If you really want to know, you can find out like this:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: which concrete class has the implementation for createStatement method