473,385 Members | 1,813 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,385 software developers and data experts.

Java UDF problem

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
Nov 12 '05 #1
4 5793

"Abram Friesen" <ab***@oax.com> wrote in message
news:e4*************************@posting.google.co m...
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?

SQL4306N generally indicates a discrepancy between the description of the
UDF in your CREATE FUNCTION statement and the method signature of the
function in your Java code. However, in your case, I don't see any such
discrepancy. (I'm assuming you've cut and pasted the CREATE FUNCTION and
Java code in EXACTLY as they are on your system; these things are very
case-sensitive.)

If you're on DB2 V8.1 on Windows, Unix, or Linux, why don't you try creating
the UDF in the Development Center, which is apparently the replacement for
the Stored Procedure Builder and which can create UDFs? If the build in the
Development Center works there, it should prove that there is nothing wrong
with your Java source code. (I'm still on DB2 V7.2 so I haven't actually
seen the Development Center yet and can't try it myself yet. I'm hand-coding
my UDFs until I can upgrade to V8).

If that doesn't help resolve the issue, I can post a simple UDF (and its
CREATE FUNCTION statement) that works for me. You could try the same code
and see if it works for you. Then maybe we could figure out what subtle
difference is messing yours up.

Rhino
Nov 12 '05 #2
Abram Friesen wrote:
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?


I just tried your UDF and it did work quite fine for me on AIX using DB2
V8.1.6.

Which version of DB2 are you using on which platform?
Do you have anything in the db2diag.log that might be relevant for the
error?
Which Java version have you installed?

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3
Did you check that all of the setup things have been done for the
instance? Do a "get dbm cfg" command from a DB2 environment command
prompt and check if the JDK_PATH variable has been properly set.

Phil Sherman
Abram Friesen wrote:
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?


Nov 12 '05 #4
Hi again,

Actually, I restarted the database manager having reset the DIAGLEVEL
to 4, and I was able to call my java udf with no problem. I still
don't understand what happened, but I'm able to move on. Thanks for
the responses!

Abram
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steven Green | last post by:
I have a java app at work I used when I had Windows 98 and never had a problem. I did a clean install of Windows XP and of course Java was not included. I went to Sun, download Java 2 Runtime...
2
by: Patrick | last post by:
I'm using Jakarta-POI to create a huge Excel spreadsheet. I get the error below when the spreadsheet grows to a large size. It seems to have something to do with the number of "cell" objects that I...
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...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
2
by: Tim Murray | last post by:
First of all, I don't know much about Java, even its naming and version numbering nomenclature, and second, if there is a better group to ask this in, please let me know. System is Mac with...
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...
6
by: Rhino | last post by:
I'm trying to debug a simple Java UDF written in the DB2General style within Eclipse. I'm getting a java.lang.UnsatisfiedLinkError when I execute the set() method in the UDF. I know that the...
14
by: mlw | last post by:
Do not take anything about this, it is not a flame or troll, while I'm not new to Java I favor C++. However, I may need to use it in a contract position, and am concerned that the restrictions it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.