But I have a little concern as we all must know that whatever classed we are using are mostly in rt.jar (in /jre/lib Package). and others are in (/jre/lib/ext) but I searched a lot about these driver classes e.g. oracle.jdbc.driver.OracleDriver. now could anyone suggest me that where are these classes situated.
Is there any difference either we use Class.forName() or we can use import statment for loading of these classes.
Why we always use Class.forName() method to load the Driver Classes, I have never seen any Program using Import statement for driver classes.
Is that so, that we cann't import these classes as we are doing for other one e.g.(java.util.*),
I have also read the API Specification of Class.forName() method it's simple stating that it is used to Load a class dynamically. But Why we need to do so, because JAVA itself use Dynamic Class loading process.
Let me know if I am wrong anywhere in my topic.
It's possible to import the driver classes like other Java classes. But it's often necessary that the same program uses different databases (and sometimes different drivers), so by keeping the class name and URL out of the code, you make it much easier to hook up the application to a different database. It's not about dynamically loading the class, but about dynamically determining which class to load, and then loading it.
What we really do is simply install jdk and try to develop an simple application of JDBC.
Actually What I really to mean is I never download any JDBC Classes jar from anywhere. I am simply using jdk but where are these classes which i am using as JDBC Drivers.
As for an example I tell you e.g. if we use java.util.HashTable it's in rt.jar in jre/lib folder...
Now as the HashTable is situated in jre/lib folder where are the JDBC driver classes in jdk.
I want to know the location of these driver classes inbuilt in jdk.
let me know if you don't understand.
Hence, you have to look for third party drivers for any particular implementation. For example, you can download the MS SQL Server drivers from Microsoft or the Oracle drivers from Oracle.
Others offer open source free drivers, like Sourceforge.
The JDK just comes with the JDBC backbone set of interfaces. They all have to be implemented by a third party driver developer.
If I am not wrong you will have to download the drivers all the time, or make them part of your installation process.
I am also agreed with your statement that initially JDK comes with basic Interfaces then if we need some specific driver then we have to download it from www. but my concern is that in my m/c when I am pretty much confident that I haven't downloaded any specific driver.
According to My Understanding I am using driver for MS-Access, I think that JDBC driver used with MS-Access is automatically installed in M/C with MS-Access Installation.
Now what might be the possible locations of these driver classes.
That's what I really want to know.??
Here is what you might be asking I don't know.
1) JDBC is an API. It's a collection of interfaces with no implementations. Implementations are provided by drivers.
2) Access drivers are ODBC and provided by Microsoft (with the OS I think I always have Office and Access installed on all my machines so I really off the top of my head could not tell you what install installs them but the basic ODBC drivers come from Microsoft anyway)
3) The JdbcOdbcBridge driver is provided by Sun as part of the JRE as a matter of convienence for you.
4) Never import driver packages or classes directly! That's a bad idea all around. (The only exception to this rule is if you are trying to use implementation specific features like Oracle blobby bits)
5) Nobody ever said the String you pass to Class.forName has to be hard coded. You could read the String at runtime from a Properties file or ask the user or any number of alternates.
The JdbcOdbcBridge driver is provided by Sun as part of the JRE as a matter of convienence for you.
Ya Now this is really I want to know, else everything I really knew already.
But Exactly what is the location of this driver in JRE is???
Pls do tell me this location in JRE Folder.
Originally posted by Ankur Sharma:
Actually I just want to see the Implementation of these classes.
How they are designed .. And One more thing is I want to have a look on design patter of these drivers.
Why are you sticking your tongue out and rolling your eyes like this? I am finding it a bit offensive to be honest as I am taking the time to answer your questions and while you said in your last post that you knew everything I said you clearly didn't in the earlier posts in this thread. Anyway please stop with the eyerolling and the tongue sticking out.
Now the answer to your question is.
No. You can't see this. The bridge driver is almost all native code anyway so it's not even Java, plus while Sun gives it away Sun did not develop the bridge driver so it's doubtful how much source you will find anyway.
If you would like to see examples of how JDBC drivers are implemented then you can look at any one of the many free open source drivers that are out there. I would recommend looking at the MySQL JConnector driver source mainly because I know it to be relatively simple.
As far as looking for design patterns in the drivers. Don't. There isn't very much to see. These are drivers implementing a known specification so the concept of design patterns in this context is very limited in scope.