We have a couple of production Java stored procedures.
Here are some things we found while testing out:
1) The Java class must reside in the following directory:
\QIBM\UserData\OS400\SQLLib\Function
2) The class had to be a member of the default package, we were
unable to get a package specific version implemented.
Other than that, we had no issue.
This is an example of our testing code:
===========================================================
Java code:
public class JavaSP {
public static void testStoredProc(String input, String [] output)
{
output[0] = "Hello " + input;
}
}
===========================================================
Stored procedure code:
DROP PROCEDURE XLIB.TESTJAVASP;
CREATE PROCEDURE XLIB.TESTJAVASP (
IN INPUTPARM CHAR(10) ,
OUT OUTPUTPARM CHAR(50) )
LANGUAGE JAVA
SPECIFIC FNDUWDGEN.TESTJAVASP
NOT DETERMINISTIC
NO SQL
CALLED ON NULL INPUT
EXTERNAL NAME 'JavaSP!testStoredProc'
PARAMETER STYLE JAVA ;
===========================================================
Execution of the stored procedure:
call xlib.testjavasp('World', '');
===========================================================
Relative to the error you are getting: Connection to relational database
AS400ADM already exists.
Some snippets of your code surrounding this area might be helpful to
diagnose further.
Russell Howard
java400-l-request
@midrange.com
Sent by: To
java400-l-bounces java400-l@xxxxxxxxxxxx
@midrange.com cc
Subject
03/25/2009 12:00 JAVA400-L Digest, Vol 7, Issue 69
PM
Please respond to
java400-l@midrang
e.com
Send JAVA400-L mailing list submissions to
java400-l@xxxxxxxxxxxx
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.midrange.com/mailman/listinfo/java400-l
or, via email, send a message with subject or body 'help' to
java400-l-request@xxxxxxxxxxxx
You can reach the person managing the list at
java400-l-owner@xxxxxxxxxxxx
When replying, please edit your Subject line so it is more specific
than "Re: Contents of JAVA400-L digest..."
Today's Topics:
1. using java for stored procedures (Mike Cunningham)
2. Re: using java for stored procedures (Jason Abreu)
3. Comparable and Generics (James Perkins)
4. RE: using java for stored procedures (Mike Cunningham)
5. RE: Comparable and Generics (Clapham, Paul)
----------------------------------------------------------------------
message: 1
date: Wed, 25 Mar 2009 10:47:39 -0400
from: Mike Cunningham <mike.cunningham@xxxxxxx>
subject: using java for stored procedures
Does anyone have a simple working stored procedure using java instead of
RPG? We have been trying to set our first one up following the Redbook but
it is not working and a simple example might get us on the right path.
Thanks
------------------------------
message: 2
date: Wed, 25 Mar 2009 11:33:08 -0400
from: Jason Abreu <abreuj@xxxxxxxxxxxxxxxxx>
subject: Re: using java for stored procedures
I am attempting to do the exact same thing right now.
My procedure appears to be executing without errors, but I cannot tell
that the procedure actually did anything. I am testing by moving data
from one test table to another. My "to" file remains empty after
execution.
:-/
Mike Cunningham wrote:
Does anyone have a simple working stored procedure using java instead of
RPG? We have been trying to set our first one up following the Redbook but
it is not working and a simple example might get us on the right path.
Thanks
------------------------------
message: 3
date: Wed, 25 Mar 2009 09:05:28 -0700
from: James Perkins <jrperkinsjr@xxxxxxxxx>
subject: Comparable and Generics
Hello All,
I'm wondering if anybody has experience implementing Comparable<T> over a
generic class. I know I could make sure the generic type implements
Comparable, but is that the only way?
Basically, I'm just creating a generic Pair class and would like to
implement Comparable, or Comparator, so that the Pair could be successfully
used in a TreeMap or any other sortable collection.
I could do this:
public class Pair<T1 extends Comparable, T2 extends Comparable> implements
Comparable<T1, T2>...
But would prefer this:
public class Pair<T1, T2> implements Comparable<T1, T2>...
If the full source would be helpful, just let me know.
Also, is there a way to make a truly immutable generic class? Something
like
adding a mutable object like Date would be immutable in the Pair object.
Normally I would just return a new Date(), but is there way to make it
immutable in another object?
Thanks in advance,
--
James R. Perkins
------------------------------
message: 4
date: Wed, 25 Mar 2009 12:21:23 -0400
from: Mike Cunningham <mike.cunningham@xxxxxxx>
subject: RE: using java for stored procedures
We are getting
Additional Message Information
Message ID . . . . . . : SQL4302 Severity . . . . . . . : 30
Message type . . . . . : Diagnostic
Date sent . . . . . . : 03/25/09 Time sent . . . . . . :
11:55:43
Message . . . . : Java stored procedure or user-defined function
KEVIN.WAKEONLAN, specific name WAKEONLAN aborted with an exception
"Connection to relational database AS400ADM already exists.".
Cause . . . . . : The Java stored procedure or user-defined function
aborted
with a Java exception. If SQJAVA component trace is on, then the
component
trace for the job contains a Java stack traceback for the aborted
method.
Recovery . . . : Debug the Java method to eliminate the exception.
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Jason Abreu
Sent: Wednesday, March 25, 2009 11:33 AM
To: JAVA400-L@xxxxxxxxxxxx
Subject: Re: using java for stored procedures
I am attempting to do the exact same thing right now.
My procedure appears to be executing without errors, but I cannot tell
that the procedure actually did anything. I am testing by moving data
from one test table to another. My "to" file remains empty after
execution.
:-/
Mike Cunningham wrote:
Does anyone have a simple working stored procedure using java instead of
RPG? We have been trying to set our first one up following the Redbook but
it is not working and a simple example might get us on the right path.
Thanks
--
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.
------------------------------
message: 5
date: Wed, 25 Mar 2009 09:21:54 -0700
from: "Clapham, Paul" <pclapham@xxxxxxxxxxxxx>
subject: RE: Comparable and Generics
The normal idiom for Comparable in Generics is "T extends
Comparable<T>". So your Pair class would look like this:
public class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2>>
implements Comparable<Pair<T1 extends Comparable<T1>, T2 extends
Comparable<T2>>
... at least I think that's right. That's assuming that your
compareTo(Pair p1, Pair p2) is going to use the compareTo methods of T1
and T2 to do the comparison.
As for immutability and generics, the two concepts are orthogonal.
PC2
-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of James Perkins
Sent: March 25, 2009 09:05
To: Java Programming on and around the iSeries / AS400
Subject: Comparable and Generics
Hello All,
I'm wondering if anybody has experience implementing Comparable<T> over
a generic class. I know I could make sure the generic type implements
Comparable, but is that the only way?
Basically, I'm just creating a generic Pair class and would like to
implement Comparable, or Comparator, so that the Pair could be
successfully used in a TreeMap or any other sortable collection.
I could do this:
public class Pair<T1 extends Comparable, T2 extends Comparable>
implements Comparable<T1, T2>...
But would prefer this:
public class Pair<T1, T2> implements Comparable<T1, T2>...
If the full source would be helpful, just let me know.
Also, is there a way to make a truly immutable generic class? Something
like adding a mutable object like Date would be immutable in the Pair
object.
Normally I would just return a new Date(), but is there way to make it
immutable in another object?
Thanks in advance,
--
James R. Perkins
--
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.
------------------------------
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
digest 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.
End of JAVA400-L Digest, Vol 7, Issue 69
****************************************
As an Amazon Associate we earn from qualifying purchases.