× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi,

java code for reading from a data queue and writing to a 
different iSeries data queue:

// Create an AS400 object for the data queue.
AS400 as400 = new AS400("localhost", "*CURRENT", "*CURRENT");
// Build a record format for the format of the dtaq entry.
// First create the base data types.
CharacterFieldDescription resultDqD =
                new CharacterFieldDescription(new AS400Text
(10, as400), "RESULT_DQ");
CharacterFieldDescription encryptpwdD =
                new CharacterFieldDescription(new AS400Text
(24, as400), "ENCRYPT_PWD")
// Build a record format and fill it with the base data types.
RecordFormat dataFormat = new RecordFormat();
dataFormat.addFieldDescription(resultDqD);
dataFormat.addFieldDescription(encryptpwdD);
// Create the data queue object that represents the dtaq on
// the AS/400.
DataQueue dq = new DataQueue(as400, "/QSYS.LIB/QGPL.LIB/" + 
DtaQ + ".DTAQ");
boolean Continue = true;
// Read the first entry off the queue.  The timeout value is
// set to -1 so this program will wait forever for an entry.
System.out.println("*** Waiting for an entry for process 
***");
DataQueueEntry DQData = dq.read(-1);
while (Continue)
{
// We just read an entry off the queue.  Put the data into
// a record object so the program can access the fields of
// the data by name.  The Record object will also convert
// the data from AS/400 format to Java format.
Record data = dataFormat.getNewRecord(DQData.getData());
// Get the value out of the record and display them.
String  resultDq   = (String)  data.getField("RESULT_DQ");
String  encryptedPassword   = (String)  data.getField
("ENCRYPT_PWD");                
System.out.println("Started decrypt password for " + 
encryptedPassword);
String clearPassword = decryptPassword(encryptedPassword);
System.out.println(clearPassword);
System.out.println("Put the result in data queue " + 
resultDq);
// Build a record format for the format of the dtaq entry.
// First create the base data types.
CharacterFieldDescription decryptpwd =
  new CharacterFieldDescription(new AS400Text(24, 
as400), "DECRY_DATA");
// Build a record format and fill it with the base data types.
RecordFormat dataFormat1 = new RecordFormat();
dataFormat1.addFieldDescription(decryptpwd);
// Create the result data queue object.
DataQueue dq1 = new DataQueue(as400, "/QSYS.LIB/QGPL.LIB/" + 
resultDq + ".DTAQ");
// Create a record based on the record format.  The record
// is empty now but will eventually contain the data.
Record data1 = new Record(dataFormat1);
// Set the values we received from the user into the record.
data1.setField("DECRY_DATA", clearPassword);
// Convert the record into a byte array.  The byte array is 
what
// is actually put to the data queue.
byte [] byteData = data1.getContents();
System.out.println("");
System.out.println("Writing data to the AS/400 ...");
System.out.println("");
// Write the record to the data queue.
dq1.write(byteData);
System.out.println(" ");
System.out.println("*** Waiting for an entry for process 
***");
// Wait for the next entry.
DQData = dq.read(-1);
}


Regards,
Magne


Date: Thu, 19 May 2005 20:35:38 +0100
From: "Larry Ducie" <Larry_Ducie@xxxxxxxxxxx> Add To Address 
Book 
Subject: Calling java from RPG - how to increase performance 
To: <java400-l@xxxxxxxxxxxx> 


Hi Aaron, Paul, Joe Sam, 

I'm quite wiling to write an all-java app. Unfortunately, I'm 
the only guy 
in our shop that's touching it so we've got "support" issues. 
The gusy are 
happy as long as the NEP is wrapped in RPG. (go figure!) So I 
am quite 
willing to rewrite as necessary. 

Joe Sam, 

Regarding my incompatible statements - The main program sits 
on a data queue 
and retrieves an XML path. It is bound to two service 
programs: 

SV1 - this handles the transformation from XML to SQL 
statements via JNI 
calls. The result is placed in a Stream file. This returns 
the file path of 
the result file. 

SV2 - this is SQLRPGLE and is passed the file path of the 
result file. It 
then reads the file line-by-line and executes the inserts via 
dynamic SQL. 

I'm perfectly happy to convert to an all-java app (I have the 
time) but you 
may have to guide me a little. 

The main thing is that the guys want the NEP to be running in 
the same 
subsystem as all of our other NEPS, it needs to be sitting on 
a data queue, 
and that's practically it. 

Any code snippets using data queues and native JDBC would be 
nice - I can 
handle the other "java" stuff. 

Also, how do I throw an exception back up to the wrapping 
Native app? 

Your help in this would be extremely welcome. 

TIA 

Larry Ducie       

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.