Adding DB2 JDBC Driver via Maven

19,655

Solution 1

You can download these files here: https://mvnrepository.com/artifact/com.ibm.db2

And use this command to add it to your local repository:

mvn install:install-file -Dfile=<path-to-file>

Maven docs.

OR you can find repository which contains jars and add it in you settings.xml file Maven docs #2

Solution 2

The DB2 java driver (Type 4 JDBC connector) has now (really for real) been published to maven central:

https://mvnrepository.com/artifact/com.ibm.db2/jcc

Include it as a dependency like so:

<!-- https://mvnrepository.com/artifact/com.ibm.db2/jcc -->
<dependency>
    <groupId>com.ibm.db2</groupId>
    <artifactId>jcc</artifactId>
    <version>11.1.4.4</version>
</dependency>
Share:
19,655

Related videos on Youtube

sovan
Author by

sovan

Updated on June 04, 2022

Comments

  • sovan
    sovan almost 2 years

    I am trying to connect to a DB2 database via the JDBC driver. I added the following entry in my pom.xml

    <!-- https://mvnrepository.com/artifact/com.ibm.db2/db2jcc_license_cu -->
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cu</artifactId>
        <version>9.7</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.ibm.db2/db2jcc -->
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc</artifactId>
        <version>8.1</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/com.ibm.db2.jcc/db2jcc4 -->
    <dependency>
        <groupId>com.ibm.db2.jcc</groupId>
        <artifactId>db2jcc4</artifactId>
        <version>10.1</version>
    </dependency>
    

    But the maven build is failing with the following issue

       [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/ibm/db2/db2jcc_license_cu/9.7/db2jcc_license_cu-9.7.pom
        [WARNING] The POM for com.ibm.db2:db2jcc_license_cu:jar:9.7 is missing, no dependency information available
        [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/ibm/db2/db2jcc/8.1/db2jcc-8.1.pom
        [WARNING] The POM for com.ibm.db2:db2jcc:jar:8.1 is missing, no dependency information available
        [INFO] Downloading from : https://repo.maven.apache.org/maven2/com/ibm/db2/jcc/db2jcc4/10.1/db2jcc4-10.1.pom
        [WARNING] The POM for com.ibm.db2.jcc:db2jcc4:jar:10.1 is missing, no dependency information available
    [ERROR] Failed to execute goal on project <somename>: Could not resolve dependencies for project
    

    How should I add the dependency for DB2 driver in maven?

    • Denilson
      Denilson almost 5 years
      I am a little skeptical about it. The pom.xml in that repository does not contain any of the typical legalese you would find in material distributed by IBM, such as a copyright statement, which is a very basic requirement for IBM to release public files (I develop software for IBM) .
  • AngocA
    AngocA over 5 years
    However, those drivers are very old.
  • AngocA
    AngocA over 5 years
    If you want to check the Db2 version of these drivers, please visit this page: angocadb2.blogspot.com/2014/08/…
  • Gunnar
    Gunnar over 4 years
    Hey Erin, could you clarify the license of this dependency? In particular, would an open-source project depending on this driver be allowed to redistribute it in its own distribution?
  • ebullient
    ebullient over 4 years
    Usage is still licensed by IPLA, as noted under Licenses in the published artifact (e.g. see mvnrepository.com/artifact/com.ibm.db2/jcc/11.5.0.0 ). While using this doesn't absolve you of having a license somewhere for DB2, it does avoid the 50 step process (mentioned above) to manually find this and cart it around. ;)
  • apa64
    apa64 about 4 years
    I wonder when they will unify the driver version with DB2 :) 11.1.4.4 is 4.25.13 and so on... looking at this: ibm.com/support/pages/db2-jdbc-driver-versions-and-downloads