This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes How methods of Interfaces in JDBC called ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "How methods of Interfaces in JDBC called ?" Watch "How methods of Interfaces in JDBC called ?" New topic
Author

How methods of Interfaces in JDBC called ?

Kousik Majumder
Ranch Hand

Joined: Sep 30, 2007
Posts: 234
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


Thanks in Advance,
Kousik
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 20080
    
  30

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
Have you checked out Aspose?
 
subject: How methods of Interfaces in JDBC called ?
 
jQuery in Action, 3rd edition