473,548 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!te stIt'
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 "SQL04081017425 5700" 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 5806

"Abram Friesen" <ab***@oax.co m> wrote in message
news:e4******** *************** **@posting.goog le.com...
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!te stIt'
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 "SQL04081017425 5700" 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!te stIt'
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 "SQL04081017425 5700" 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
24725
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 Environment, SE v 1.4.2 and Java 2 Runtime Environment SE v 1.4.1_01. The Java app will not work with WinCP. I have installed the Windows XP Service...
2
3938
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 create. If I destroy other objects that I don't need any more, then I can create more "cell" objects. Unfortunately, I cannot destroy any more of...
13
6572
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 which checks for fresh updates, then installs them, then launches the game client. We have begun our beta test, and would like to have the client open...
133
8456
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
2
9206
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 problems doing this. I wanted to implemented a generic "Helper" class like this: /** * Helper
2
3134
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 procedures. It is enabled for SQL stored procedures. It is possible to "Build" and "Run" the Java SPs, it just isn't possible to click on the...
2
13506
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 10.4.4. I have Java 1.3.1 and 1.4.2 plug-ins, and J2SE 5.0 (1.5.0) installed. The Java preferences application lets me choose J2SE 5 or 1.4.2 to run...
1
9599
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
6
2423
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 UnsatisfiedLinkError has something to do with a DLL that is not visible but I'm not sure why I'm having the problem given that both db2java.zip and...
14
5656
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 places on application code. Take, for instance, this C++ construct: class foo { char *m_name;
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7438
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.