?
Solved

Invoking DB2 Stored Procedure using Java PreparedStatement

Posted on 2002-04-10
3
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
asharma2 earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

764 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