473,549 Members | 2,639 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 3409
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
1773
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...
2
6653
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...
4
5017
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...
7
7089
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...
2
3322
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. ...
1
1638
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
2683
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
1255
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Is there any way I can access .net application through mainframe.
2
5745
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
7462
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...
0
7975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6059
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...
0
3510
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...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1957
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
1
1069
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
777
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.