Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

which concrete class has the implementation for createStatement method

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic