File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Identifying JDBC driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Identifying JDBC driver" Watch "Identifying JDBC driver" New topic
Author

Identifying JDBC driver

Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Can anyone help on how do I make out which type JDBC driver I am using?

I mean to say how can I identify the driver type?

Thanks in advance.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
I'd start with the driver's documentation.
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 193

using above method you can identify.


SCJP 5, SCWCD 5
Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Prabhakar Reddy Bokka wrote: using above method you can identify.


I wrote something like this


and it gave output as:



So I am not getting the exact type here.
Can you help me out?
Abhishek Ralhan
Ranch Hand

Joined: Aug 01, 2010
Posts: 40

Why don't you look into driver documentation. I am sure you will get the answer.
Otherwise, this is what I found when i googled, may be you would be interested in:

http://hsqldb.org/doc/src/org/hsqldb/jdbcDriver.html

which says,

int getMajorVersion() Gets the driver's major version number.
int getMinorVersion() Gets the driver's minor version number.

it has two methods to get the versin of your driver.
Is that what you are looking for??


-Abhishek
I came to this world on a Learner's License
Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Abhishek Ralhan wrote:Why don't you look into driver documentation. I am sure you will get the answer.
Otherwise, this is what I found when i googled, may be you would be interested in:

http://hsqldb.org/doc/src/org/hsqldb/jdbcDriver.html

which says,

int getMajorVersion() Gets the driver's major version number.
int getMinorVersion() Gets the driver's minor version number.

it has two methods to get the versin of your driver.
Is that what you are looking for??


Abhishek,

I am not looking for versions.
I am looking for TYPE such TYPE I or TYPE II etc.
Sandeep Sanaboyina
Ranch Hand

Joined: Dec 14, 2009
Posts: 72
As Lester said, you better start looking at the driver documentation.

I don't think you can identify driver type with java methods.


They say you have to be the first, the best or different. I say, is it too much to ask for all three.
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Sumukh Deshpande wrote:
I am not looking for versions.
I am looking for TYPE such TYPE I or TYPE II etc.


Try getDriverName - http://www.hsqldb.org/doc/src/org/hsqldb/jdbc/jdbcDatabaseMetaData.html
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16


What makes you think that the Driver type will be included in the Driver name ?


[My Blog]
All roads lead to JavaRanch
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Christophe Verré wrote:

What makes you think that the Driver type will be included in the Driver name ?


Where did I say that it will be included? It works for JSQLConnect driver and could work for others too.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Where did I say that it will be included?

Sandeep asks for the Driver Type, and you tell him to use getDriverName.

It works for JSQLConnect driver and could work for others too.

Never assume anything. If the API doesn't tell you what the returned value is, it may be vendor specific.
For your interest, this is what I got with Oracle's driver: "Oracle JDBC driver".
Sumukh Deshpande
Ranch Hand

Joined: Feb 17, 2008
Posts: 87

Christophe Verré wrote:
Where did I say that it will be included?

Sandeep asks for the Driver Type, and you tell him to use getDriverName.

It works for JSQLConnect driver and could work for others too.

Never assume anything. If the API doesn't tell you what the returned value is, it may be vendor specific.
For your interest, this is what I got with Oracle's driver: "Oracle JDBC driver".


So does it mean there is no way we cam find out the TYPE programatically?
I have tried my best but didn't get an answer.

Abhishek Ralhan
Ranch Hand

Joined: Aug 01, 2010
Posts: 40

Yes, i do not think so.

Why don't you search in the documentation provided with the driver..?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Or, to put it another way, what would a piece of code do differently once it knows which type of driver it's using?
Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
Christophe Verré wrote:
Where did I say that it will be included?

Sandeep asks for the Driver Type, and you tell him to use getDriverName.


I said "try". For me it means it may work and may not.

Christophe Verré wrote:
It works for JSQLConnect driver and could work for others too.

Never assume anything. If the API doesn't tell you what the returned value is, it may be vendor specific.
For your interest, this is what I got with Oracle's driver: "Oracle JDBC driver".


Please don't try to put words in my mouth. Once again, I just said "could work", but I didn't say that it would work in all cases.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Sumukh Deshpande wrote:So does it mean there is no way we cam find out the TYPE programatically?


Why would you want to do that anyway?
 
Don't get me started about those stupid light bulbs.
 
subject: Identifying JDBC driver