By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

Smple java UDF not working: SQL4306N

P: n/a
Folks, I've written the world's simplest java UDF, and it is complaining that it can't load the method. The class seems OK, it's complaining about the method.

The JDBC Sample UDFs (e.g., scUDFReturningErr) seem to work fine, so I made sure that I'm doing everything the same way the sample is.

My class file is in the right place. My method is public. I'm using the IBM 1.4.1 JDK that came with my DB2 (v8.2.2). I'm using the InfoCenter and Don Chamberlin's book as sources of info.

Anyone know what's wrong with this:

C:\temp>javac myClass.java

C:\temp>db2stop force
11/19/2005 16:58:11 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.

C:\temp>killdb2

C:\temp>copy myClass.class "C:\Program Files\IBM\SQLLIB\function"
1 file(s) copied.

C:\temp>dir "C:\Program Files\IBM\SQLLIB\function\myClass.class"
Volume in drive C has no label.
Volume Serial Number is CC7D-89B5

Directory of C:\Program Files\IBM\SQLLIB\function

19/11/2005 04:58 PM 365 myClass.class
1 File(s) 365 bytes
0 Dir(s) 9,758,330,880 bytes free

C:\temp>db2start
11/19/2005 16:58:14 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.

C:\temp>db2 -tvf myUdf.db2
connect to sample

Database Connection Information

Database server = DB2/NT 8.2.2
SQL authorization ID = LMENARD
Local database alias = SAMPLE
drop function myUdf (integer)
DB20000I The SQL command completed successfully.

create function myUdf (integer)
returns integer
external name 'myClass!myMethod'
fenced
parameter style db2general
language java

DB20000I The SQL command completed successfully.

drop table myTable
DB20000I The SQL command completed successfully.

create table myTable (myColumn int)
DB20000I The SQL command completed successfully.

insert into myTable values (123)
DB20000I The SQL command completed successfully.

!del "C:\Program Files\IBM\SQLLIB\DB2\db2diag.log"

!db2 update dbm cfg using diaglevel 4
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.

select myUdf(myColumn) from myTable

1
-----------
SQL4306N Java stored procedure or user-defined function "LMENARD.MYUDF",
specific name "SQL051119165815800" could not call Java method "myMethod",
signature "(II)V". SQLSTATE=42724

!db2 update dbm cfg using diaglevel 3
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.

connect reset
DB20000I The SQL command completed successfully.

terminate
DB20000I The TERMINATE command completed successfully.

C:\temp>

The UDF source:

/* */

import java.lang.*; // for String class
import COM.ibm.db2.app.*; // UDF and associated classes

public class myClass extends UDF
{
public void myUdf ( Integer inVar,
Integer outVar )
throws Exception
{
set(2, 9);
}
}

The info in diag.log is not helpful (to me at least)... basically it just says the same thing... JNI GetMethodID failed.

2005-11-19-16.58.18.366000-300 I21084H387 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:130
MESSAGE : JNI GetMethodID failed. class:
DATA #1 : Hexdump, 7 bytes
0x01A3D420 : 6D79 436C 6173 73 myClass

2005-11-19-16.58.18.366000-300 I21473H389 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:140
MESSAGE : JNI GetMethodID failed. method:
DATA #1 : Hexdump, 8 bytes
0x01A3D428 : 6D79 4D65 7468 6F64 myMethod

2005-11-19-16.58.18.381000-300 I21864H389 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:150
MESSAGE : JNI GetMethodID failed. signature:
DATA #1 : Hexdump, 5 bytes
0x01A3D450 : 2849 4929 56 (II)V

2005-11-19-16.58.18.381000-300 E22255H375 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejLogException, probe:10
MESSAGE : ADM10000W A Java exception has been caught. The Java stack
traceback has been written to the db2diag.log.

2005-11-19-16.58.18.381000-300 I22632H383 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejLogException, probe:10
MESSAGE : java.lang.NoSuchMethodError: myMethod
DATA #1 : Hexdump, 4 bytes
0x01C3F424 : 0000 0000 ....

2005-11-19-16.58.18.397000-300 I23017H925 LEVEL: Error
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, oper system services, sqlofica, probe:10
DATA #1 : Hexdump, 136 bytes
0x01C3FCDC : 5351 4C43 4120 2020 8800 0000 2EEF FFFF SQLCA .........
0x01C3FCEC : 2F00 4C4D 454E 4152 442E 4D59 5544 46FF /.LMENARD.MYUDF.
0x01C3FCFC : 5351 4C30 3531 3131 3931 3635 3831 3538 SQL0511191658158
0x01C3FD0C : 3030 FF6D 794D 6574 686F 64FF 2849 4929 00.myMethod.(II)
0x01C3FD1C : 5620 2020 2020 2020 2020 2020 2020 2020 V
0x01C3FD2C : 2020 2020 2020 2020 5351 4C45 4A45 5854 SQLEJEXT
0x01C3FD3C : 0000 0000 0000 0000 0000 0000 0000 0000 .................
0x01C3FD4C : 0000 0000 0000 0000 2020 2020 2020 2020 ........
0x01C3FD5C : 2020 2034 3237 3234 42724

I notice that my class file is only 365 bytes in size. Keeping in mind the simplicity of the method, is that unusual?

I appreciate any suggestions.

Thanks.

--
--------------------
Larry Menard
"Defender of Geese and of All Things Natural"
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I finally figured this out.

1.. In the parameter list of the method I should have specified datatype "integer", not "Integer", and
2.. The method name in the java code should have been "myMethod", not "myUdf" (really kicking myself over that one).

--
--------------------
Larry Menard
"Defender of Geese and of All Things Natural"
"Larry Menard" <ro**@GoSpamYourself.com> wrote in message news:0N********************@rogers.com...
Folks, I've written the world's simplest java UDF, and it is complaining that it can't load the method. The class seems OK, it's complaining about the method.

The JDBC Sample UDFs (e.g., scUDFReturningErr) seem to work fine, so I made sure that I'm doing everything the same way the sample is.

My class file is in the right place. My method is public. I'm using the IBM 1.4.1 JDK that came with my DB2 (v8.2.2). I'm using the InfoCenter and Don Chamberlin's book as sources of info.

Anyone know what's wrong with this:

C:\temp>javac myClass.java

C:\temp>db2stop force
11/19/2005 16:58:11 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.

C:\temp>killdb2

C:\temp>copy myClass.class "C:\Program Files\IBM\SQLLIB\function"
1 file(s) copied.

C:\temp>dir "C:\Program Files\IBM\SQLLIB\function\myClass.class"
Volume in drive C has no label.
Volume Serial Number is CC7D-89B5

Directory of C:\Program Files\IBM\SQLLIB\function

19/11/2005 04:58 PM 365 myClass.class
1 File(s) 365 bytes
0 Dir(s) 9,758,330,880 bytes free

C:\temp>db2start
11/19/2005 16:58:14 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.

C:\temp>db2 -tvf myUdf.db2
connect to sample

Database Connection Information

Database server = DB2/NT 8.2.2
SQL authorization ID = LMENARD
Local database alias = SAMPLE
drop function myUdf (integer)
DB20000I The SQL command completed successfully.

create function myUdf (integer)
returns integer
external name 'myClass!myMethod'
fenced
parameter style db2general
language java

DB20000I The SQL command completed successfully.

drop table myTable
DB20000I The SQL command completed successfully.

create table myTable (myColumn int)
DB20000I The SQL command completed successfully.

insert into myTable values (123)
DB20000I The SQL command completed successfully.

!del "C:\Program Files\IBM\SQLLIB\DB2\db2diag.log"

!db2 update dbm cfg using diaglevel 4
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.

select myUdf(myColumn) from myTable

1
-----------
SQL4306N Java stored procedure or user-defined function "LMENARD.MYUDF",
specific name "SQL051119165815800" could not call Java method "myMethod",
signature "(II)V". SQLSTATE=42724

!db2 update dbm cfg using diaglevel 3
DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.

connect reset
DB20000I The SQL command completed successfully.

terminate
DB20000I The TERMINATE command completed successfully.

C:\temp>

The UDF source:

/* */

import java.lang.*; // for String class
import COM.ibm.db2.app.*; // UDF and associated classes

public class myClass extends UDF
{
public void myUdf ( Integer inVar,
Integer outVar )
throws Exception
{
set(2, 9);
}
}

The info in diag.log is not helpful (to me at least)... basically it just says the same thing... JNI GetMethodID failed.

2005-11-19-16.58.18.366000-300 I21084H387 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:130
MESSAGE : JNI GetMethodID failed. class:
DATA #1 : Hexdump, 7 bytes
0x01A3D420 : 6D79 436C 6173 73 myClass

2005-11-19-16.58.18.366000-300 I21473H389 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:140
MESSAGE : JNI GetMethodID failed. method:
DATA #1 : Hexdump, 8 bytes
0x01A3D428 : 6D79 4D65 7468 6F64 myMethod

2005-11-19-16.58.18.381000-300 I21864H389 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejCallJavaRoutine_dll, probe:150
MESSAGE : JNI GetMethodID failed. signature:
DATA #1 : Hexdump, 5 bytes
0x01A3D450 : 2849 4929 56 (II)V

2005-11-19-16.58.18.381000-300 E22255H375 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejLogException, probe:10
MESSAGE : ADM10000W A Java exception has been caught. The Java stack
traceback has been written to the db2diag.log.

2005-11-19-16.58.18.381000-300 I22632H383 LEVEL: Warning
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, BSU Java support, sqlejLogException, probe:10
MESSAGE : java.lang.NoSuchMethodError: myMethod
DATA #1 : Hexdump, 4 bytes
0x01C3F424 : 0000 0000 ....

2005-11-19-16.58.18.397000-300 I23017H925 LEVEL: Error
PID : 3344 TID : 2908 PROC : db2fmp.exe
INSTANCE: DB2 NODE : 000
FUNCTION: DB2 UDB, oper system services, sqlofica, probe:10
DATA #1 : Hexdump, 136 bytes
0x01C3FCDC : 5351 4C43 4120 2020 8800 0000 2EEF FFFF SQLCA .........
0x01C3FCEC : 2F00 4C4D 454E 4152 442E 4D59 5544 46FF /.LMENARD.MYUDF.
0x01C3FCFC : 5351 4C30 3531 3131 3931 3635 3831 3538 SQL0511191658158
0x01C3FD0C : 3030 FF6D 794D 6574 686F 64FF 2849 4929 00.myMethod.(II)
0x01C3FD1C : 5620 2020 2020 2020 2020 2020 2020 2020 V
0x01C3FD2C : 2020 2020 2020 2020 5351 4C45 4A45 5854 SQLEJEXT
0x01C3FD3C : 0000 0000 0000 0000 0000 0000 0000 0000 .................
0x01C3FD4C : 0000 0000 0000 0000 2020 2020 2020 2020 ........
0x01C3FD5C : 2020 2034 3237 3234 42724

I notice that my class file is only 365 bytes in size. Keeping in mind the simplicity of the method, is that unusual?

I appreciate any suggestions.

Thanks.

--
--------------------
Larry Menard
"Defender of Geese and of All Things Natural"
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.