• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

How methods of Interfaces in JDBC called ?

 
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JDBC connection we use different methods other than DriverManager class. All of them are Interfaces.
1. My question is then how do we call the methods of interfaces?
2. If the answer is it calls a class that implements these interface then which class is this?


Thanks

Kousik
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Kousik Majumder:
In JDBC connection we use different methods other than DriverManager class. All of them are Interfaces.
1. My question is then how do we call the methods of interfaces?


DriverManager uses the connection string to find a concrete class. This class is part of the database specific driver; the only real thing you can tell is that it implements Connection.

The thing is, you're not getting interfaces back from those methods. Instead, they return some concrete class that implements that interface. Because the methods specify to return an interface, the same code could be used with a different type of database; only the connection string needs to be modified.

Look for polymorphism for more info.

2. If the answer is it calls a class that implements these interface then which class is this?


Well that depends on the driver.

For MySQL, it's com.mysql.jdbc.Connection, for MSSQL 2005 it's com.microsoft.sqlserver.jdbc.SQLServerConnection.

The thing is, you don't need to know what the actual class is; just program using the interfaces and you're code will work just find, and it will be easier to switch to a different database type.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!