*
The moose likes Beginning Java and the fly likes Where is defination of inbuilt interfaces are written? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where is defination of inbuilt interfaces are written?" Watch "Where is defination of inbuilt interfaces are written?" New topic
Author

Where is defination of inbuilt interfaces are written?

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
As questioned above, I am slight confused with it when i tracked classes

let me take example of JDBC Connection (i have not posted it in JDBC because asking it in general sense)

Example :


Register Driver is called within driver manager and the driver given in Argument is registered shown code below:


then getConnection is called and in procedure of getConnection it calls CONNECT() method if



When i see CONNECT method, i found it in DRIVER interface as shown below:

Connection connect(String url, java.util.Properties info)
throws SQLException; <----------- Picture ends here amd Connection type is returned....unable to find further role and control of "jdbc:oracle:thin:@12.16.5.1:11:vqa", "en", "e123"


Question is how connect acted internally(connect to db) ?
As it is interface, where is it's definition of connection?
Does JVM holds that internally? or JVM takes control?
i mean how it executes?

I hope you understand my question......sly i found for many things in java....

please respond


Regards
Azrael Noor
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Specific to your question, the Driver Interface would be implemented by the provider of the driver, in your case it would be Oracle, since you are using Oracle driver. The implementation is never present in the JVM. The implementation needs to be provided by the vendors.

Hope this helps.


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Sumit ok I am getting into Oracle Driver Class now which is registered above

It contains following overridden on Driver.....please see below



I am unable to find control here too
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

This class will have compiled code, where they have implemented it.
You can use a decompiler to see the implementation details.

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Yes Bro i am studying it

I have used this J Decompiler: http://java.decompiler.free.fr/?q=jdgui

I found




Let me study, it i will ask question again :p

Thank you for your help......i am reaching to the place where JVM actually takes whole control...i mean where control goes non visible to me :p

will ask again, if any problem occurs
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

You are welcome
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Azrael Noor wrote:
When i see CONNECT method, i found it in DRIVER interface as shown below:

Connection connect(String url, java.util.Properties info)
throws SQLException; <----------- Picture ends here amd Connection type is returned....unable to find further role and control of "jdbc:oracle:thin:@12.16.5.1:11:vqa", "en", "e123"


Question is how connect acted internally(connect to db) ?
As it is interface, where is it's definition of connection?


When you call DriverManager.getConnection(), it looks at its registered Drivers until it finds one that can understand the particular URL you've passed. In this case, it finds the OracleDriver, and asks it for a Connection. The driver returns an instance of a concrete class that implements the Connection interface. We don't know and we don't care what the specific class is.

(And by the way, you should not be doing DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()). You shouldn't need to instantiate it. Just call Class.forName("oracle.jdbc.driver.OracleDriver") and it should register itself, and manage its own instantiation.)

Does JVM holds that internally? or JVM takes control?
i mean how it executes?


It executes just like any other code. You call a method, which class another method, and so on. These methods make use of various classes that are on the classpath. The classes may be your own, or part of the core API, or may have come from some third party library. It doesn't matter; it's all executed the same way.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Sumit Patil wrote:The implementation is never present in the JVM.


Yes it it. The implementing class, like any other class, has to be loaded into the JVM at runtime in order to execute its code.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Where is defination of inbuilt interfaces are written?
 
Similar Threads
interview question
need help on dynamic loading of jdbc driver
"Unable to load JdbcOdbc library". Help please?!
Problem in connecting to DB2 using JDBC
a mistake for bean