Solved

Invoking DB2 Stored Procedure using Java PreparedStatement

Posted on 2002-04-10
3
247 Views
Last Modified: 2006-11-17
I am having a problem with Java Client for DB2 stored procedure. I am using PreparedStatement and setting data using setString() function. In some cases when I have large buffer size the data is getting misaligned on the mainframe side due to some binary/invalid chars getting appended before the string.

Following is the Stored Procedure I/O Structure:

Field Name     DATA TYPE     INPUT/OUTPUT     SIZE
_____________________________________________________
HDRCNTL             VARCHAR          INPUT          300
INORDERNO     CHAR          INPUT          9
INGENL          CHAR          INPUT          91
INDATA          VARCHAR          INPUT          29942
COMMAREA     VARCHAR          OUTPUT          400
_____________________________________________________

I am using setString() to set all the input data elements. The data received on mainframe has 2 additional chars in the beginning of INDATA string. I tried using setBytes() also and that doesn't work either. I am looking for solution to avoid the 2 chars getting on mainframe DB2.


Thanks much.
0
Comment
Question by:ArshadAQ
3 Comments
 

Accepted Solution

by:
asharma2 earned 50 total points
Comment Utility
Hi Arshad,
      Are you running the java program in NT/Unix?If so then problem here might be because of different encoding pattern accross the platform.In mainframe encoding pattern is EBCDIC and in NT/Unix it is ASCII.SO before doing the set string you need to first translate the ASCII to EBCDIC then do setString.If setString doesn't work then instead of prepareStatement use directly variable in Query.
      You can get several translation program available in net..one such is http://www.room42.com/store/computer_center/java_translate.shtml.

Good luck.

Regards
Alok

0
 
LVL 5

Expert Comment

by:vemul
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- points to asharma2

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
allStar challenge 1 41
wordmultiple challenge 12 89
maven example error 3 34
Java passing arguments (type error) 2 33
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now