473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Smple java UDF not working: SQL4306N

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
1 6025
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
55
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I...
4
by: Abram Friesen | last post by:
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...
5
by: claus.hirth | last post by:
If I create the function HELLO in schema S01 as follows, @ CREATE FUNCTION S01.HELLO() RETURNS VARCHAR(32) EXTERNAL NAME 'UDFSRVXYZ!sayHelloWorld' LANGUAGE JAVA PARAMETER STYLE DB2GENERAL NO...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.