Hi all,
I'm a newbie at DB2 and trying to create a simple java UDF. When I
call my function, I'm receiving SQL4306N. Could someone please tell me
what I'm doing wrong here?
Here is my java code for a UDF that simply returns the integer value
you pass it:
import java.sql.*;
class ACFTestFunc extends COM.ibm.db2.app.UDF {
public void testIt(int inValue, int result) throws Exception {
set(2,inValue);
}
}
I compile and copy the class file into the sqllib/function directory.
Here is the CREATE FUNCTION statement:
db2 => CREATE FUNCTION testIt(INTEGER) RETURNS INTEGER
EXTERNAL NAME 'ACFTestFunc!testIt'
not fenced
language java
parameter style db2general
no sql
no external action
dbinfo;
I get the " The SQL command completed successfully." message. I follow
that with a GRANT EXECUTE ON FUNCTION:
db2 => GRANT EXECUTE ON FUNCTION testIt(INTEGER) TO PUBLIC WITH GRANT
OPTION;
Again I receive the " The SQL command completed successfully."
message. Everything seems to have gone well up until this point. Then
I call the function:
db2 => connect to sample;
db2 => select testit(1) from employee;
and I receive SQL4306N :
SQL4306N Java stored procedure or user-defined function "DB2.TESTIT",
specific name "SQL040810174255700" could not call Java method
"testIt",
signature "(II)V". SQLSTATE=42724
What am I doing wrong?
Thanks in advance,
Abram Friesen