• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC to connec to DB2 UDB z/OS database

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all:
I've searched on this wonderful ranch far and wide and have found shadows and pieces of things that I am searching. I am hoping that the cattle that rustle up the dust will settle down for a while to let the dust clear so that I may find a definitive answer.
Environment:
Client: Win XP-Pro, JAVA application, compiled using the 'old-fashion' method of a "C:" prompt and finally figuring out how to get a clean compile with the -classpath and file names in the correct sequence. It was like a rooky roping a steer, all trial and error with a little jibing from the old hands that stood by and chuckled, however, I finally did it.
Still using the "C:" prompt, I attempted to execute my JAVA.class and, with the same cow-hands looking on just getting dustier and not really helping out, I figured out the syntax and incorporated the -cp (classpath) and the several files, separated by semi-colons and then the right spacing.
The Server: DB2 UDB z/OS database. I have been able to use the IBM (PC-based) application developer to get a successful connection to that system and talk and share information, so I know I've got the ODBC parameters in the system working.
The execution: IT's the same topic that many other greenhorns have been frustrated getting from their executions: "java.sql.SQLException: No suitable driver".
It's frustrating after all the research that is incomplete that says, "you need a classpath" definition to point to the driver file. Well, here's the rub: there are at least three places that I've found that one can possibly make classpath definitions, 1) with a "C:" set command, 2) in the JAVAC command and 3) in the JAVA command. It boggles my mind that if JAVA is a "compile-once use anywhere" language, why doesn't it include the driver in at compile (JAVAC) time, but also needs it at run (JAVA) time? But, that's not important, right now to me.
What's important is where did I mess up and why doesn't it work?
client code snippet follows:
String url = "jdbc b2 71A";
try {
Class.forName( "COM.ibm.db2.jdbc.net.DB2Driver" );
connection = DriverManager.getConnection(
url, username, password );
}
I've also tried the "....jdbc.app.DB2Driver" variation, too.
Yes, I have supplied other parameters for username and password in earlier code.
So, then my guru friends I do the following, JAVAC:
javac -g d:\javajdbc\DisplayQueryResults.java -classpath d:\db2v813base\java\db2java.zip
compiles cleanly, then I run:
java -cp d:\javajdbc;d:\db2v813base\java\db2java.zip DisplayQueryResults
Where I then get:
Unable to connect
java.sql.SQLException: No suitable driver
So, what name can i use to search using the power of window's search to once and for all resolve this nagging issue?
Thank you in advance for your sticking with the long, but i hope, complete explaination.
Regards,
Gary Joehlin
Colorado Springs, CO
Near the Flying "W" ranch
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, this is kind of a shot in the dark, but I believe package names are case sensitive. So where you have
Class.forName( "COM.ibm.db2.jdbc.net.DB2Driver" );
I wonder if it should be
Class.forName( "com.ibm.db2.jdbc.net.DB2Driver" );
Now, the reason you aren't getting compile time errors is because Class.forName doesn't do anything until runtime. So the compiler doesn't care about it.
To answer an earlier question you said wasn't important:
It boggles my mind that if JAVA is a "compile-once use anywhere" language, why doesn't it include the driver in at compile (JAVAC) time, but also needs it at run (JAVA) time?
When you compile a java program, javac takes your source code and compiles it down to byte-code. And here is the catch, it ONLY compiles your source code. When you use classpath to tell javac where a library is located, javac uses that path to resolve packages and libraries used in your source code. But it doesn't compile anything into your byte-code. Sooooo, when it is time to run your program using java, the VM still needs to know where to find those libraries your program is dependent on. That ZIP file or JAR file you are referencing in your classpath already has the byte code. It doesn't get compiled again.
Now, back to your REAL problem. Let me know if the case of the COM made any difference.
[ September 18, 2003: Message edited by: Gregg Bolinger ]
 
Gary Joehlin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gregg,
You are correct! The driver name IS case sensitive. However, the documentation (the little that there is of it) and a recompile and execute when I changed to lowercase (com. yadda yadda...) give me a "failed to load driver" condition, so i put it back to upper case and am now back to "Unable to connect... Error opening socket", which gives me reason to believe that I'm closer to a solution with it in uppercase than lowercase.
Thanks dude, I appreciate the info!
Still looking for the solution. I know it has to exist, or is this a ruse by JAVA and IBM to keep us busy? lol
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, now I am a little confused. You said that the first error you got was "Unable to load driver.." right? And so when you changed COM to com, you get "failed to load driver" or you get "Unable to connection...Error opening socket".
The best thing for you to do for me now so I can help is give me the entire Exception when you use COM and the entire exception when you use com. You are right, we are close. I just need a tad bit more info.
Thanks.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gary,
I beleave you just need to add the following in your classpath when you start your application using java command:
d:\db2v813base\java\runtime.zip;
Garry
 
Gary Joehlin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gary martin:
I think that maybe you missed a key point or maybe I missed that point, so if you're familiar with this please let me know.
It is my observation that the ~runtime.zip is for SQLJ, not JDBC. Because, when I search for the "file name contains" runtime.zip on my machine, it returns sqlj-runtime.zip listings.
I'm not using sqlj, that's for another time and I find it tempting to go there, however, I need to resolve this JDBC issue first.
If you have other ideas, please continue to pass them along.
Regards,
Gary J.
Colo Spgs
 
Gary Joehlin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gary Marten,
Sorry I spelled your name incorrectly.
Just wanted to add another piece of information.
When I searched for the runtime file, it was not part of the DB2 UDB distribution, but part of VAJ (VisualAge for JAVA), which does support SQLJ and JDBC.
I am developing a standalone JAVA application that needs to be portable, so that's why I have not employed SQLJ.
Thanks again,
Gary J.
COS
 
Gary Joehlin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gregg:
Sorry about the confusion.
After further examination, from numerous conflicting sources, I found the consensus to be that COM should be capitalized. Additionally, I have found that the format of the 'url' string to be in great flux and variation. I have reasoned, that many offers are for different client-platforms. Which is why I think that the combination of: 1) the url, 2) the Class.forName and 3) javac ... -classpath and java -cp
are all suspect, which means, I haven't got solid evidence on the proper combination. Following are my tries and results:
Notes:
I am able to PING the IP address and it comes back ok.
I am able to use the DB2 UDB (PC-based) Configuration Assistant to successfully connect to and query the server database. Therefore, I know that a) the connection between my PC and the server (a z/OS platform) works and b) that the server Database system is there and is replying to my simple query. "SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1;" and it returns, as expected, the current date.
===============================================================
Setup:
javac -g d:\javajdbc\DisplayQueryResults.java -classpath d:\db2v813base\java\db2java.zip;d:\db2v813base\java\db2jcc.jar
java -cp d:\javajdbc;d:\db2v813base\java\db2java.zip;d:\db2v813base\java\db2jcc.jar DisplayQueryResults
================================================================
Secnario 1:
String url = "jdbc b2://xx.xxx.xx.xxx:446/D71A";
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
Results:
COM.ibm.db2.jdbc.DB2Exception: [IBM] {JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01
[trace omitted]
==================================================================
Secnario 2: (Changed case of COM to com)
String url = "jdbc b2://xx.xxx.xx.xxx:446/D71A";
Class.forName("com.ibm.db2.jdbc.net.DB2Driver").newInstance();
Results:
java.lang.ClassNotFoundException: com.ibm.db2.jdbc.net.DB2Driver
[trace omitted]
====================================================================
Secnario 3: Changed format of url string. COM back to all caps.
String url = "jdbc b2 71A";
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
Results:
java.sql.SQLException: No suitable driver
[trace omitted]
====================================================================
Secnario 4: Changed "net" to "app" in Class.forName. All other parms back to values in Scenario 1.
String url = "jdbc b2://xx.xxx.xx.xx:446/D71A";
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
Results: (Same as Scenario 3)
java.sql.SQLException: No suitable driver
[trace omitted]
======================================================
This leads me to believe that there is something within the -classpath/-cp parameters that needs to be changed/added (probably changed). I'm more than glad to change it, however, what is it that I'm looking for to be included during the javac/java processes, then I can search for them in some .jar or .zip file, if i knew for sure.
Your continued kindness is very much appreciated.
Regards,
Gary Joehlin
COS
 
Gary Joehlin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear followers (the two of you, so far) of this link.
Here's an irony I've discovered, quite by accident (you'd be surprised on how many frivilous details that stick in your brain when you're searching for something, but the peripheral items keep calling out to you) in my search for my holy graile.
It seems that a simple little innocuous thing, like a software firewall, can wreck havoc on trying to debug a pc-based JDBC request to an IBM (z/OS aka MVS) DB2 server, get in the way.
If you've been following my post(s), the past one suggests that the first scenario is what I have determined, by a 'filtered consensus' to be the most likely candidate to make things happen. But, alas, it was not successful, then I looked at my software firewall and it said that "java.exe" was BLOCKED from sending and receiving any communications. So, I quickly changed it to allow outbound only, and the error message changed to one that gives me belief that my server finally is being contacted by my request.
I went to the server, because I have super authority to query (DDF on the MVS spool, for those that are curious) and found that I have indeed piqued its curiosity. However, according to the cryptic message I found there, regarding my attempt to talk to it, the format of my request was 'not proper'.
Now, I move forward to find the answer to other obscure TCP/IP error codes on a UNIX-IBM box, we mainframers have UNIX and MVS (the traditional op/sys for IBM mainframes) combined together under a single skin and today we call that op/sys z/OS.
So, I still am looking for confirmation:
1) of my JDBC parameters to be confirmed as proper
2) the definition parameters in the PC interface software called DB2 Connect (there are several ways to implement them, through a wizard-- which doesn't give access to all the parameter options, or through the Command Line Processor (CLP) supplied with DB2 UDB (the PC/Windows version) which I found in an obscure reference on the web.
3) the definition and parameters on the Unix system Server and TCP/IP on the IBM mainframe.
Not asking for much, am I? lol
I hope that some one can help if not in all categories, the at least one.
Your kindness is very much appreciated.
Regards,
Gary joehlin
Colo Spgs, CO
 
reply
    Bookmark Topic Watch Topic
  • New Topic