| Author |
How methods of Interfaces in JDBC called ?
|
Kousik Majumder
Ranch Hand
Joined: Sep 30, 2007
Posts: 219
|
|
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: 19216
|
|
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
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: How methods of Interfaces in JDBC called ?
|
|
|