This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes finding Driver Type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "finding Driver Type" Watch "finding Driver Type" New topic
Author

finding Driver Type

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Can anoyone explain me how I can find what Type of driver is available on my machine.
I know there are four types of drivers I just want to identify the Drivers Type
installed on my machine by using java program or something.


SCJP 1.2
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
You'll need to know what drivers you have, and then you can look them up at
http://developers.sun.com/product/jdbc/drivers. There's no way to run a Java program and have it tell you what drivers are available (unless you iterate through all classes in your classpath, and outputs all those that implement java.sql.Driver or javax.sql.DataSource).


Ping & DNS - my free Android networking tools app
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

By far the easiest way is to remember what type it is when you download a driver and add it to your classpath.

Otherwise, you can interogate the driver to get named properties using the java.sql.DriverPropertyInfo class.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Swapan Mazumdar
Ranch Hand

Joined: Jul 23, 2003
Posts: 83
Originally posted by Anurag Mishra:
Can anoyone explain me how I can find what Type of driver is available on my machine...

Anurag,

So far I understand those "JDBC Drivers" are different in their own respect and not necessarily be found on the same host system.
Let me explain you.
1) If you are on windows, ODBC is available by default so you can use "Type 1 JDBC-ODBC Bridge Drivers" which uses a bridge technology to connect a Java client to an ODBC database system
So you have ODBC in your windows(very much so I guess) you have the "Driver"

2) If you have oracle client for example installed on your system then I guess you can use "Type 2 Native-API Partly Java Drivers" which wraps a thin layer of Java around the native library (i.e OCI)

3) You can pehaps use "Type 3 Net-protocol All-Java Drivers" which is kind of proprietary to the vendor could be a middleware service provider to provide the actual database access

4) I suppose you can use "Type 4 Native-protocol All-Java Drivers" which is pure java drivers. These are .jar files that need to be lying on your classpath to be able to use it.(I use those drivers (jar files to access mysql database / sql server). If you don't have it you need to download it first.

Hope I have explained you a bit.

cheers,
Swapan
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All,

Thanks for your reply the link http://developers.sun.com/product/jdbc/drivers
was useful.

I was loking for this driver which type it belongs to
oracle.jdbc.driver.OracleDriver()

I feel its type4.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Anurag Mishra:

I feel its type4


Don't assume anything..check your connection string
if your connection string is like


then It is JDBC Thin Driver Type 4 driver connection

and if it is like

then it is JDBC OCI Driver the Type 2 JDBC driver connection

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
By the way, is there any preference in using thin Vs OCI driver.
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Originally posted by Alec Lee:
By the way, is there any preference in using thin Vs OCI driver.


you should use the OCI driver for maximum performance and the Thin driver for maximum portability. However, It is recommended using the Thin driver all the time.

The JDBC OCI driver uses native methods, there can be significant Performance advantages in using this driver for your applications.

If you are using a JDBC OCI driver in an application with oracle, then the application will require an Oracle installation on its clients. For example, the application will require the installation of Net8 and client libraries.


Shailesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: finding Driver Type