Solved

Invoking DB2 Stored Procedure using Java PreparedStatement

Posted on 2002-04-10
3
253 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
ID: 6932768
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
ID: 7898837
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
ID: 7959842
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 77
numbers ascending pyramid 101 191
servlet example issue 6 38
Java string replace 11 43
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.

786 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