IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

JDBC Connectivity using Data Studio jar files


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Rai Raman

New User


Joined: 28 Feb 2013
Posts: 2
Location: South Africa

PostPosted: Sun Jul 21, 2013 9:22 pm
Reply with quote

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
View user's profile Send private message
Rai Raman

New User


Joined: 28 Feb 2013
Posts: 2
Location: South Africa

PostPosted: Sun Jul 21, 2013 9:58 pm
Reply with quote

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
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Mon Jul 22, 2013 6:43 pm
Reply with quote

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. icon_smile.gif

Anyway, thanks for sharing that the issue is resolved.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Mon Jul 22, 2013 11:15 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Jul 23, 2013 12:13 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts How to save SYSLOG as text data via P... All Other Mainframe Topics 4
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Write line by line from two files DFSORT/ICETOOL 7
Search our Forums:

Back to Top