Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where is Connection interface implemented

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
We get a object of type Connection thru DriverManager.getConnection() method. But, where are the iplementation of this Connection inteface. I couldn't find any class/interface that implements/extends this Connecion interface
 
Amol Deshmukh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shankar,
JDBC API is mostly consisting of interfaces. So that most commonly used objects are the implementation of these interfaces. As u will see that Connection, Statement, PreparedStatement, CallableStatement, ResultSet, etc. are all interfaces. So who provides the implementation? The answer is that the JDBC driver is what provides the implementation of all these interfaces.
When you make a call as :-
DriverManager.getConnection("dbUrl", "username", "password");
The DriverManager class check out with all the registered drivers if they recognize the dbUrl. If any of the drivers recognizs the dbUrl, then the DriverManager uses that Driver class to get the Connection object. The Connection object in this case is the implementation of the Connection interface as provided by the driver. Similarly the implementation for all other interfaces like Statement, ResultSet etc are provided by the Driver.
Hope this clarifies your doubt.
-A/D.
 
Amol Deshmukh
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi shankar,
JDBC API is mostly consisting of interfaces. So that most commonly used objects are the implementation of these interfaces. As u will see that Connection, Statement, PreparedStatement, CallableStatement, ResultSet, etc. are all interfaces. So who provides the implementation? The answer is that the JDBC driver is what provides the implementation of all these interfaces.
When you make a call as :-
DriverManager.getConnection("dbUrl", "username", "password");
The DriverManager class check out with all the registered drivers if they recognize the dbUrl. If any of the drivers recognizs the dbUrl, then the DriverManager uses that Driver class to get the Connection object. The Connection object in this case is the implementation of the Connection interface as provided by the driver. Similarly the implementation for all other interfaces like Statement, ResultSet etc are provided by the Driver.
Hope this clarifies your doubt.
Amol Deshmukh
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amol Deshmukh,
Ya,I got it, Thanks. Sun provides just the set interfaces in the java.sql package and any third-pary people can implement it based on the spec, Right.
Now, I am looking a Tool which generates a Java file given a class file. I hope there are some Tool for this one. Please let me know i any.
Thanks
Shankar S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic