Connect to Db2 on z/OS from Windows. Connection failed due to a license error

160 Views Asked by At

I've installed Db2 Connect in Windows and I load the license successful:

Product name:                     "DB2 Connect Enterprise Edition"
License type:                     "Client Device"
Expiry date:                      "Permanent"
Product identifier:               "db2consv"
Version information:              "11.1"

When I'm trying to connect with JDBC it indicates there is a license error:

java -cp %CLASSPATH%;./db2jcc.jar com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://xx.yy.zz.pp:port/DB -user USER -password PASSWORD -db2ConnectVersion "C:\Program Files\IBM\SQLLIB\java\db2jcc_license_cu.jar"


[jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://xx.yy.zz.pp:port/DB -user USER -password ******** -db2ConnectVersion C:\Program Files\IBM\SQLLIB\java\db2jcc_license_cu.jar


DB2 V11.1
[jcc][10512][13714]Failed to create connection.
  SQLCODE: -4230
  SQLSTATE: 42968
  Message: [jcc][t4][10509][13454][3.72.54] Connection to the data server failed. The IBM Data Server for JDBC and SQLJ license was invalid
or was not activated for the DB2 for z/OS subsystem. If you are connecting directly to
the data server and using DB2 Connect Unlimited Edition for System z, perform the
activation step by running the activation program in the license activation kit.
If you are using any other edition of DB2 Connect, obtain the license file,
db2jcc_license_cisuz.jar, from the license activation kit, and follow the installation
directions to include the license file in the class path. ERRORCODE=-4230, SQLSTATE=42968

Anyone can help me please?

2

There are 2 best solutions below

0
Hogstrom On

The issue is that the Db2 JDBC driver has a need for a license file. You need to supply this on the class path which you are not currently doing.

Your original command is:

java -cp %CLASSPATH%;./db2jcc.jar com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://xx.yy.zz.pp:port/DB -user USER -password PASSWORD -db2ConnectVersion "C:\Program Files\IBM\SQLLIB\java\db2jcc_license_cu.jar"

Change it to:

java -cp %CLASSPATH%;C:\Program Files\IBM\SQLLIB\java\db2jcc_license_cu.jar;./db2jcc.jar com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://xx.yy.zz.pp:port/DB -user USER -password PASSWORD -db2ConnectVersion "C:\Program Files\IBM\SQLLIB\java\db2jcc_license_cu.jar"

Review this article from IBM on how to use the Db2 License Files

Also, you might review this Stack Overflow question Where can I get these two jars - db2jcc4_license_cu and db2jcc4_license_cisuz?

0
Pasamonte On

Both files are jars. They need to be in the classpath. One is the jdbc connector itself and the other one is the license to make it work.

Both have to be downloaded from the system where the connection will be established because the need to match the Db2 for z/OS version.

They are usually under the /usr/lpp/db2something path where SMP/E installs the FMID for the JDBC connectors.

And you don’t need Db2 Connect to use JDBC, you just need to add the correct classpath where the Java code will establish the connection.

If you want to connect from your Windows system to a Db2 on z/OS using JDBC instead of ODBC (Db2 Connect) which is complex to install, I would do this:

  1. Use VSCode with the Db2 Developer Extension. Documentation.
  2. Get the jar files with the JDBC and the license and configure JDBC for the developer extension.
  3. You’ll need:
    • Db2 location name
    • Hostname (or IP) for the system where Db2 is located
    • Access port for DDF
    • Userid and password with granted access to the Db2 schemas you want to work with.

This extension is quick, easy to use and gives you all the VSCode flexibility for working with Db2.