× 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.



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




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.