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

Have you checked the contents of SYSJAROBJECTS, SYSJARCONTENTS, and
/QIBM/UserData/OS400/SQLLib/Function. Also, the InfoCenter shows that the
external name clause should be jarid:classname.methodname. However, you
have a ! separating the classname and methodname.

I'm assuming that you left off the package name from the Functions3DB2 class
definition in this email.

HTH,
Gary

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of David Gibbs
Sent: Friday, April 03, 2009 6:36 AM
To: Java Programming on and around the iSeries / AS400
Subject: Problem with a java SQL UDF

Folks:

A co-worker of mine is trying to setup a Java user defined function in
DB2/400 ... but we can't get it to work.

The function is very simple ...

----------

import COM.ibm.db2.app.UDF;
import COM.ibm.db2.app.Clob;
import java.io.Reader;

public class Functions3DB2 extends UDF {

public void testFunc3(int b, int a, int res) throws Exception
{
int blah = b+a;
set(3,blah*2);
}
----------

After copying the jar containing the class to the /tmp ifs directory we
installed it, into schema kmorton3, using the following SQL commands ...

----------
- call sqlj.install_jar('file:/tmp/kev3.jar','kmorton3.mksis3',0)
- create function testFunc3(b int, a int) returns int
specific testFunc3
deterministic
language java
parameter style db2general
no dbinfo
fenced
returns null on null input
external name 'mksis3:mks.ci.server.schema.Functions3DB2!testFunc3'

----------

When we try to run the function, we get the following error ...

----------
select testFunc3(1,2) from fields where ID=-1

[SQL4306] Java stored procedure or user-defined function TESTFUNC3,
specific
name TESTFUNC3 could not call Java method testFunc3, signature (III)V.
Cause
. . . . . : The Java method given by the EXTERNAL NAME clause of a
CREATE
PROCEDURE or CREATE FUNCTION statement could not be found. Its declared
argument list may not match what the database expects, or it may not be a
"public" instance method. Recovery . . . : Ensure that a Java instance
method exists with the "public" flag and the expected argument list for
this
call.
----------

I'm not super familiar with UDF's ... can anyone help out here?

Is the function being created correctly in SQL?

Is the java method's signature correct?

Thanks!

david



--
IBM i on Power - For when you can't afford to be out of business
--
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 ...

Follow-Ups:
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.