473,687 Members | 3,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accessing mainframe DB2 in Java.

Hello,

I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?

Thanks,

Zalek
Mar 22 '08 #1
9 3421
zalek wrote:
I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?
Usually (possible always) the JDBC driver will throw an SQLException
if not success.

Arne
Mar 22 '08 #2
On Mar 22, 5:14 pm, Arne Vajhøj <a...@vajhoej.d kwrote:
zalek wrote:
I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?

Usually (possible always) the JDBC driver will throw an SQLException
if not success.

Arne
Yes - I know - but I would like to know what exactly happen. For
example - if I try to access a table using a variable as a key - I
would like to know "not found conditions" occurred to display correct
message. If database was down - I would like to know it too. Is there
a way in a java world to find it?

Thanks,

Zalek
Mar 22 '08 #3
zalek wrote:
Hello,

I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
Run Zalek!

Run to the light!

Mar 22 '08 #4
zalek wrote:
Hello,

I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?

Thanks,

Zalek
I'm going to guess:

I see SQLException has a constructor that takes a vendor specific return
code ("vendorCode "). I think you'll have to either 1) parse the
toString() result (or similar string result) or 2) use reflection to
peek at the internal vendorCode variable.

Ugly as it is, I think the second method might actually be more reliable.
Mar 22 '08 #5
zalek wrote:
On Mar 22, 5:14 pm, Arne Vajhøj <a...@vajhoej.d kwrote:
>zalek wrote:
>>I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?
Usually (possible always) the JDBC driver will throw an SQLException
if not success.

Yes - I know - but I would like to know what exactly happen. For
example - if I try to access a table using a variable as a key - I
would like to know "not found conditions" occurred to display correct
message. If database was down - I would like to know it too. Is there
a way in a java world to find it?
e.getErrorCode( ) will give you SQLCODE number.
e.getSQLState() wil give you SQLSTATE number.
e.getMessage() will give you the entire message.

Example:

} catch (SQLException e) {
System.out.prin tln(e.getErrorC ode());
System.out.prin tln(e.getSQLSta te());
System.out.prin tln(e.getMessag e());

print:

-104
42601
DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC:
END-OF-STATEMENT;SELEC T x* FROM T1;<table_expr>

Arne
Mar 22 '08 #6
Arne Vajhøj wrote:
zalek wrote:
>On Mar 22, 5:14 pm, Arne Vajhøj <a...@vajhoej.d kwrote:
>>zalek wrote:
I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
How do you check for this conditions in Java?
Usually (possible always) the JDBC driver will throw an SQLException
if not success.

Yes - I know - but I would like to know what exactly happen. For
example - if I try to access a table using a variable as a key - I
would like to know "not found conditions" occurred to display correct
message. If database was down - I would like to know it too. Is there
a way in a java world to find it?

e.getErrorCode( ) will give you SQLCODE number.
Duh. You know I looked right at that in the Javadocs and because it
didn't say "getVendorC ode" I didn't read any further? Ouch.
Mar 22 '08 #7
zalek wrote:
Hello,

I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.
In a Cobol world after each SQL command we are checking for return
conditions like success (sqlcode=0), not found (sqlcode = +100),
duplicates (sqlcode=803) and more.
If you intend to write to the db directly, rather than via ORM, then I'd
recommend using Spring's JDBC facilities. Their approach to this issue
is to rethrow much more specific exceptions outlining what went wrong. I
find this to be marginally better, but the real benefit of Spring here
is getting rid of all that horrid boiler plate code that one must write
with straight JDBC. If your intent is to learn, then try a few methods
both ways and see for yourself.

--
Shane
Mar 23 '08 #8


Mark Space wrote:
zalek wrote:
Hello,

I am a mainframe Cobol programmer (yes - Cobol programmers are still
around, mostly in caves) and I am writing a java code to access DB2.

Run Zalek!

Run to the light!
As verbose and ungainly as Cobol is, I'd prefer it any day to Java.
Then again, I'd prefer a sharp object in the eye to Java.

Mickey - Rexx rules :)))))
Mar 25 '08 #9
On Mar 25, 2:14 pm, Mickey <mick...@comcas t.netwrote:
As verbose and ungainly as Cobol is, I'd prefer it any day to Java.
And you are right! Stay in your world.
It's wonderful and amazing.
Never saw anything like this one.
They even blame Java in their own faults...

We had project where we had connection to at least half of dozen
different database platforms. But only DB2 Connect tried to charge us
for $6,000 for single query. From mainframe side, of course. And they
killed this project because it was "too expensive to connect to DB2".

It was very efficient to connect to DB2 with Cobol (but they didn't
tell us what price would it be). However it was impossible to connect
to other databases from mainframe side and project was finally
canceled as impossible to create.

Alex.
http://www.myjavaserver.com/~alexfromohio/
Mar 25 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1787
by: John | last post by:
"Unisys, one of the few companies remaining in the mainframe market, will begin selling a new high-end system Monday that includes features to run advanced software. The new ClearPath Plus Libra 185 comes with faster processors and more capacity for transferring data into and out of the system. As significant a change is the support for programs written using Microsoft's .Net infrastructure and Sun Microsystems' Java." ...
2
6663
by: Chris New | last post by:
G'Day All I am having trouble dynamically assigning a value to a table's cell from one frame to another frame. I've created a website that is primarily viewed in a frameset consisting of 2 frames - a navigation frame (navFrame) at the top and a contents frame (mainFrame) on the bottom. In all instances, the mainFrame displays a single page except in one case, where it was necessary to use a frameset consisting of a left frame...
4
5030
by: karpagam | last post by:
Since WebServices are a standardized way to invoke a method of another application over the internet, is there a way to integrate two different applications running on different platforms (Say a .NET client application, used for implementing the presentation logic, and a mainframe application that contains the business logic). Is there a way to call the .NET web service from the mainframe application / expose the buiness logic in the...
7
7107
by: David Laub | last post by:
I've also posted this issue to a Sun/java formum, but since it appears to be an integration issue, this may be the better place to posr: I have written a dot net/c# Web Services doesn't fully work with J2ME client a) c# web service works with c# WIndows Client (local & remote web service) b) c# web service works with J2ME client - when the Web Service is local c) c# web service fails with J2ME client - when the Web Service is remote ...
2
3327
by: vikas.bhatia | last post by:
Is this still true? http://groups.google.com/group/comp.databases.ibm-db2/browse_thread/thread/58c6c36ce9006d50/778f98749d8e2983?lnk=st&q=DB2+Connect+product+license&rnum=6#778f98749d8e2983 would a standard type 4 driver, jar file copy into the WEB-INF/lib folder not work? I am trying to access db2 8 on z/os though a java app server. thanks.
1
1641
by: Gil Lapid | last post by:
Hi, What is the recommended way to develop DB2 Mainframe application without buying this expensive hardware/software ? I'd like to develop the software for a Mainframe customer. Thanks, Gil
6
2693
by: R. Vince | last post by:
I'm been roped into a techical discussion next week as to whether our Java applet / php site can run on a "mainframe." (I know not what kind of "mainframe" or OS). Is this kind of thing even in the realm of possibility? Or should i tell them to rewrite the whole thing in COBOL? Thanks
3
1260
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Is there any way I can access .net application through mainframe.
2
5755
by: agjoshi | last post by:
How to read the datafile using java with the data written using mainframe? Mainframe consists of some compressed characters need to be uncompress using Java & extract original text. How to do that?
0
8527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9070
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7621
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6453
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5806
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4543
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.