1

I have developed a small utility for reading database tables and I'm trying to access DB2 tables. I am using DB2 for z/OS and my application is a standalone JAR file that you have to execute in command line using java -jar. Also, I have the db2jcc_license_cu.jar license that I received from a DBA. I already tried to pack this license in my JAR application, but I always get this error:

[jcc][t4][10509][13454][4.21.29] 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

The connection url is jdbc:db2://<server>:<port>/<schema_name>:progressiveStreaming=2; which should be a Type 4 connection. I am using the Universal DB2 Driver. I don't know if including license jar is sufficient to make things work or if I need something more, like loading license or similar operations.

Any help will be appreciated.

I. Ahmed
  • 2,438
  • 1
  • 12
  • 29
Lorelorelore
  • 3,335
  • 8
  • 29
  • 40
  • Your question is incomplete, because you don't state whether you are going *direct* to the Z/os, or *indirect* (via a gateway software product such as Db2-connect). This choice determines the required action, as indicated by the message. If you don't know which , then ask your DBA. – mao May 29 '18 at 08:13
  • I am using only the JDBC driver. I don't know if I am going direct or not, my DBA gave me the license and said that I had to include it in my application. – Lorelorelore May 29 '18 at 08:17
  • That's not enough information. It is *mandatory* to know whether you are attempting a direct connection to z/OS or an indirect connection *because different licensing activities are required*. Go back and talk with your DBA . – mao May 29 '18 at 08:18

3 Answers3

1

As far as I remember, db2jcc_license_cu.jar needs to be on the classpath of the application in order for the JDBC driver to pick it up.

As you are starting your application with java -jar ... you can't specify additional jarfiles on the command line.

So you have two options:

  1. Include db2jcc_license_cu.jar in your MANIFEST.MF when you build your application's jar file. Then you need to drop it into the same place as the other jar files referenced in the manifest.

  2. Start your application specifying all jars using the -cp parameter:

    java -cp yourjar.jar;db2jcc4.jar;db2jcc_license_cu.jar your.main.Class
    

Note that the above example uses the Windows path separator. If you run your application on Linux you need to use : instead of ;

  • Just a question: using Maven I have built my application with maven-assembly-plugin, with jar-with-dependencies descriptor. It should be the same thing of the options that you are suggesting to me, but still I get that exception. Am I missing something? – Lorelorelore May 29 '18 at 07:38
  • @Lorelorelore: is the license jar listed in the manifest? If yes, is it stored where it can be found at runtime? –  May 29 '18 at 07:41
  • At the moment the license jar is included in my application jar. All other dependancies are loaded with no errors. None of then has the entry in the classpath. However, i will try the first option you proposed me. – Lorelorelore May 29 '18 at 07:43
  • You can't include a jar inside a jar (unless you "explode" the embedded jar). –  May 29 '18 at 07:44
  • Yes, I "exploded" it. – Lorelorelore May 29 '18 at 07:46
  • However... I've tried adding the manifest entry as you suggested and got the same error. Option 2 also didn't work. – Lorelorelore May 29 '18 at 07:57
  • Turns out that our customer, who was in charge of executing our application, was using the wrong separator for jar files. The second option worked perfectly. – Lorelorelore Jul 09 '18 at 14:03
0

If you are using Eclipse IDE, it includes a facility that builds a project as a single JAR file (Export as Runnable JAR):

How to create a jar with external libraries included in Eclipse?

Stavr00
  • 3,219
  • 1
  • 16
  • 28
0

i passed 4 hours trying to do that, and finally i use jt400.rar and it works fantastic!

Raul Guerrero
  • 388
  • 2
  • 10