View previous topic :: View next topic
|
Author |
Message |
Rai Raman
New User
Joined: 28 Feb 2013 Posts: 2 Location: South Africa
|
|
|
|
Hi all,
Has anybody tried using the jar files that come with IBM Data Studio in a custom java program?
I'm trying to connect to a DB2 db on Z/OS, and while I can do that using Data Studio with no issues, I keep getting a class not found exception when I run the custom java program.
Code: |
c:\temp2>dir
Volume in drive C has no label.
Volume Serial Number is 3206-6E75
Directory of c:\temp2
21/07/2013 17:00 <DIR> .
21/07/2013 17:00 <DIR> ..
09/04/2012 03:07 3,507,640 db2jcc.jar
09/04/2012 03:07 2,068 db2jcc_license_cisuz.jar
21/07/2013 17:07 2,973 EzJava.class
21/07/2013 17:13 3,195 EzJava.java
4 File(s) 3,515,876 bytes
2 Dir(s) 51,066,073,088 bytes free
c:\temp2>java -cp . EzJava
**** Enter class EzJava
Could not load JDBC driver
Exception: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at EzJava.main(EzJava.java:21)
|
I've decompiled the jars and the class that the JVM cannot find is definitely there.
Thanks in advance,
Rai |
|
Back to top |
|
|
Rai Raman
New User
Joined: 28 Feb 2013 Posts: 2 Location: South Africa
|
|
|
|
Ok, I should really go back to Java 101.
Compile your code with both jar files:
Code: |
javac -cp ./db2jcc.jar;./db2jcc_license_cisuz.jar EzJava.java |
Then, run with both jar files:
Code: |
java -cp .;./db2jcc.jar;./db2jcc_license_cisuz.jar EzJava |
And that should work!
Regards,
Rai |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Did someone just ask a question and answer it themselves?
Which is fine, but I was amused with the way it was answered.. like different person answering a question.
Anyway, thanks for sharing that the issue is resolved. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
I think s/he was providing the solution to the next poor soul who has to do this so they were writing to that person. Makes sense? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Yup, I suspect that there will be more people doing this sort of thing.
This is probably something that will help multiple people going forwqard.
d |
|
Back to top |
|
|
|