× 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 all,

I think this might be the cleanest way to handle our situation, however,
one question.  How do we set the classpath?  We don't really want to use
the system's environment classpath because it is different than what we
need and it doesn't seem like a good idea to add a bunch of unless
classes & jars just to execute the single class.  We would simply prefer
to say "if you're executing this class, use this classpath".  That way
we keep the system's environment clean for other things.

Thanks!
Kelly

 

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jessica King
Sent: Friday, March 16, 2007 6:14 AM
To: 'Java Programming on and around the iSeries / AS400'
Subject: RE: Call a Java program from RPG or CL

Kelly Jones wrote:
 
We have a situation where we need to call a Java program, have it do 
"it's thing", then pass a return code back to the calling program.  
The main point of the return code is to inform the calling program 
whether everything went OK.  If the Java program bombs, we need to 
inform the caller that something bad happened and stop.
 
Can someone provide an example how to do this?

When we need to do this, we create a Java Stored Procedure. The
procedure can define the input and output parameters like this:

CREATE PROCEDURE Libray.ProcName ( 
        IN SomeVariable VARCHAR(25) , 
        OUT ErrorCode Integer ) 
        LANGUAGE JAVA 
        NOT DETERMINISTIC 
        MODIFIES SQL DATA 
        EXTERNAL NAME 'com.yourcompany.ClassName!methodName' 
        PARAMETER STYLE JAVA ; 

Your class goes in the /UserData/OS400/SQLLib/Function/ directory or is
available through the classpath.

Then your CL or RPG (or whatever) can call the stored procedure in a SQL
statement just like it would any other stored procedure.

This works well for us. The Java program can catch exceptions or handle
different types of problems and return an appropriate error code. We
always return 0 if there were no problems.
************************************************************************
**************************
The contents of this email and any attachments are confidential.
They are intended for the named recipient(s) only.
If you have received this email in error please notify the system
manager or  the sender immediately and do not disclose the contents to
anyone or make copies.

** eSafe scanned this email for viruses, vandals and malicious content.
**
************************************************************************
**************************


--
This is the Java Programming on and around the iSeries / AS400
(JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/java400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.