Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How methods of Interfaces in JDBC called ?

 
Kousik Majumder
Ranch Hand
Posts: 237
  • 0
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • 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