aspose file tools*
The moose likes JDBC and the fly likes How we know which JDBC version we are using Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How we know which JDBC version we are using" Watch "How we know which JDBC version we are using" New topic
Author

How we know which JDBC version we are using

Pankaja Shinde
Ranch Hand

Joined: Sep 15, 2006
Posts: 87
How we know which JDBC version we are using?

Thanks

Pankaj Shinde
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

I am not very sure about this.

It depends on the database. For DB2, db2java.zip is for Type 2 and db2jcc.jar is for Type 4. You can read about the product documentation and the name of the jar/zip file you use for the JDBC Driver.

I don't think there is something like Manifest.mf file as that of jar file, with which you can find out the version of JDBC driver.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39549
    
  27
You can (sort of) infer the JDBC version from the JRE version.
  • 1.0 and 1.1 -> JDBC 1
  • 1.2 and 1.3 -> JDBC 2
  • 1.4 and 5 -> JDBC 3
  • 6 -> JDBC 4


  • Ping & DNS - updated with new look and Ping home screen widget
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    Ulf, this gives a different direction

    I thought the OP asked about how to deduce from the jdbc jar file! But do you mean to say that the versions did NOT support the other types?
    Marilyn de Queiroz
    Sheriff

    Joined: Jul 22, 2000
    Posts: 9043
        
      10
    We are using using JRE 1.4. Some of the code (written mostly under JDK 1.2/1.3) works only with the (db2java.zip) Type 2 driver, some of it works only with the (db2jcc.jar) Type 4 driver, and some of the java code works with both.


    JavaBeginnersFaq
    "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    Thank You Marilyn de Queiroz.

    Now i really doubt what was the intention of Original Poster! Was it with respect to the JDBC Driver or the JRE version?

    Also, is it true that the particular JRE version does support ONLY a certain type of JDBC drivers? I never had a thought on this!
    Jeanne Boyarsky
    internet detective
    Marshal

    Joined: May 26, 2003
    Posts: 29257
        
    140

    Originally posted by Raghavan Muthu:
    Now i really doubt what was the intention of Original Poster! Was it with respect to the JDBC Driver or the JRE version?

    When we talk about the JDBC Driver, there are two numbers associated with it. There is the type (type 1, 2, 3 or 4) and version of the JDBC spec supported (JDBC 3, JDBC 4, etc)


    Also, is it true that the particular JRE version does support ONLY a certain type of JDBC drivers? I never had a thought on this!

    No, multiple JRE versions can work with the same driver. My comment applies to both the type of the driver and the version of the spec. There are some dependencies between JRE versions and versions of the JDBC spec, but it's not always one to one.


    [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    amit punekar
    Ranch Hand

    Joined: May 14, 2004
    Posts: 507
    Hello,
    This can be done using two methods in Driver interface.
    - java.sql.Driver.getMajorVersion() j
    - java.sql.Driver.getMinorVersion().

    Please correct me if I am wrong.

    Regards,
    Amit


    Regards,
    Amit
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    Originally posted by Jeanne Boyarsky:

    When we talk about the JDBC Driver, there are two numbers associated with it. There is the type (type 1, 2, 3 or 4) and version of the JDBC spec supported (JDBC 3, JDBC 4, etc).


    That is another point to be noted and added Thank you Jeanne!

    I am aware of the JDBC spec version and also some versions of JDBC are implemented in the JRE versions.

    I guess Ulf also told the same. Now only it did strike me
    [ January 19, 2008: Message edited by: Raghavan Muthu ]
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    Originally posted by Jeanne Boyarsky:

    No, multiple JRE versions can work with the same driver. My comment applies to both the type of the driver and the version of the spec. There are some dependencies between JRE versions and versions of the JDBC spec, but it's not always one to one.


    Yes, thats very true Jeanne. But what Marilyn told also of the same with the the type of jdbc driver (1,2,3,4) with the JRE and NOT with the spec! That's why i asked such a question.

    Now i think the the Original Poster might have asked the JDBC Spec version and NOT the jdbc driver type version! , by looking at the way you and Ulf replied!
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    Originally posted by amit punekar:
    Hello,
    This can be done using two methods in Driver interface.
    - java.sql.Driver.getMajorVersion() j
    - java.sql.Driver.getMinorVersion().



    Yes amit. You can get the JDBC Spec version being supported through these methods!
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 39549
        
      27
    Originally posted by Raghavan Muthu:
    Now i think the the Original Poster might have asked the JDBC Spec version and NOT the jdbc driver type version!

    There is no such thing as a "driver type version". We don't know what the OP was asking about, but there are 3 numbers to keep apart: the JDBC version in use (which I outlined above), the JDBC driver version (which Amit talked about), and the driver type.

    For compatibility it's important that the JDBC version is larger or equal to the JDBC driver version. In other words, the JRE must support a JDBC version that is at least as new as the version supported by the driver.
    Raghavan Muthu
    Ranch Hand

    Joined: Apr 20, 2006
    Posts: 3344

    That's very true Ulf. I also got and told the same about OP's intention.

    Thank you
    Raees Uzhunnan
    Ranch Hand

    Joined: Aug 15, 2002
    Posts: 126
    If you are looking at the file from which the driver is loaded take a look at this site

    Finding from where the java class is loaded
    http://javaonthefly.blogspot.com/2008/01/finding-from-where-java-class-is-loaded.html

    Thanks
    Raees


    Sun Certified Enterprise Architect
    Java Technology Blog
    Pankaja Shinde
    Ranch Hand

    Joined: Sep 15, 2006
    Posts: 87
    Just I want to know which JDBC API I am using. Is it 1.0 or 2.0 or 3.0 or 4.0. As I am getting problems for the code that uses JDBC API 2.0, i.e. code using Scrollable ResultSet(Following link shows my post that encounters this problem, heading com.mysql.jdbc.NotUpdatable ...).

    http://www.coderanch.com/t/306460/JDBC/java/com-mysql-jdbc-NotUpdatable-Result

    That's why I want to confirm that am I using JDBC API 2.0 or not. I got correct results for code that uses JDBC API 1.0. Actually problem is in my code (I forgot to set primary key).

    I really thanks to all of you. Specifically Ulf Dittmer and Raghavan Muthu for such a valuable discussion.

    Thanks
    Pankaj Shinde
    SCJP
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How we know which JDBC version we are using
     
    Similar Threads
    JDBC Driver spec number?
    JDBC Help
    new to jsp
    RAD 7.5 and Hibernate
    About the web.xml