473,385 Members | 1,838 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.

UnsatisfiedLinkError in Java UDF

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 db2jcc.jar are visible on my classpath and each of
them contain the COM.ibm.db2.app.UDF class with a variety of set() methods,
including the one that I am trying to execute. I've also tried removing
db2java.zip from the classpath to see if that would help prevent the error
but it didn't.

Does anyone have any idea how I can solve this problem?

This is the UDF. By the way, I'm pretty sure there are no errors in it and I
know the code is trivial; I'm just trying to debug it with Eclipse to prove
that I can. Another UDF I wrote that also grabs the leftmost characaters of
a String works fine but it is written in style "Java" and is therefore
missing the set() method.

---------------------------------------------------------------------------------------------------------------------
public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);

set(3, leftmost);
}
---------------------------------------------------------------------------------------------------------------------

I'm using Eclipse 3.1.1 and DB2 V8.1.8.762 on Windows XP (SP2).

--
Rhino
Apr 26 '06 #1
6 2414
Rhino wrote:
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 db2jcc.jar are visible on my
classpath and each of them contain the COM.ibm.db2.app.UDF class with a
variety of set() methods, including the one that I am trying to execute.
I've also tried removing db2java.zip from the classpath to see if that
would help prevent the error but it didn't.

Does anyone have any idea how I can solve this problem?

This is the UDF. By the way, I'm pretty sure there are no errors in it and
I know the code is trivial; I'm just trying to debug it with Eclipse to
prove that I can. Another UDF I wrote that also grabs the leftmost
characaters of a String works fine but it is written in style "Java" and
is therefore missing the set() method.

--------------------------------------------------------------------------------------------------------------------- public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);

set(3, leftmost);
}

---------------------------------------------------------------------------------------------------------------------

How did you register the function in your database, i.e. what's the exact
CREATE FUNCTION statement?

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 28 '06 #2

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e2**********@lc03.rz.uni-jena.de...
Rhino wrote:
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 db2jcc.jar are visible on my
classpath and each of them contain the COM.ibm.db2.app.UDF class with a
variety of set() methods, including the one that I am trying to execute.
I've also tried removing db2java.zip from the classpath to see if that
would help prevent the error but it didn't.

Does anyone have any idea how I can solve this problem?

This is the UDF. By the way, I'm pretty sure there are no errors in it
and
I know the code is trivial; I'm just trying to debug it with Eclipse to
prove that I can. Another UDF I wrote that also grabs the leftmost
characaters of a String works fine but it is written in style "Java" and
is therefore missing the set() method.

---------------------------------------------------------------------------------------------------------------------
public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);

set(3, leftmost);
}

---------------------------------------------------------------------------------------------------------------------

How did you register the function in your database, i.e. what's the exact
CREATE FUNCTION statement?

Sorry for the delay in replying; I spent most of yesterday trying things
that were implied by your note....

This is the definition of the leftmost() UDF function that was in effect
when I posted my question:

--------------------------------------------------------------------
CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME 'TextUDFs_Java:com.foo.java.TextUDFs.leftmost'

LANGUAGE JAVA

PARAMETER STYLE JAVA

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;

--------------------------------------------------------------------

The leftmost() function works just fine from the command line when defined
this way and I can debug it in Eclipse too; I can step through every
statement of the UDF and the driver. Naturally, the method is defined
somewhat differently than shown in my original post though; this is the
source code for leftmost(), as written for parameter style Java, stripped to
its bare bones:

---------------------------------------------------------------------------------------------------------------------
public static String leftmost(String input, int size) throws
SQLException {

try {
String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String output = trimmedInput.substring(0, size);
return (output);
} catch (Exception excp) {
throw new SQLException("leftmost() - " + excp.getMessage(),
"38600");
}
---------------------------------------------------------------------------------------------------------------------
However, when I use the code shown in the first post of this thread and I
replace the definition of the leftmost() function with this:

--------------------------------------------------------------------

CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME 'TextUDFs_DB2General:com.foo.db2general.TextUDFs.l eftmost'

LANGUAGE JAVA

PARAMETER STYLE DB2GENERAL

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;

--------------------------------------------------------------------

I get an UnsatisfiedLinkError when I reach the set() statement at the end of
the method during debugging in Eclipse. The function still works just fine
from the command line.

Do you have any idea what I need to change in order to be able to debug my
function in Eclipse and step through all of the statements, _including_ the
set()?

The leftmost() function itself is trivial but I want to be able to debug
more ambitious functions, like ones that include SQL and table UDFs as well,
once I get this very basic function working.

I can always write diagnostic lines to a logging file if I have to for
debugging purposes but I'd rather just use Eclipse if that is possible. It
is considerably less cumbersome to simply step through the real code with a
good debugger than it is to add diagnostic code to my program.

--
Rhino
Apr 30 '06 #3
Rhino wrote:

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e2**********@lc03.rz.uni-jena.de...
Rhino wrote:
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 db2jcc.jar are visible on my
classpath and each of them contain the COM.ibm.db2.app.UDF class with a
variety of set() methods, including the one that I am trying to execute.
I've also tried removing db2java.zip from the classpath to see if that
would help prevent the error but it didn't.

Does anyone have any idea how I can solve this problem?

This is the UDF. By the way, I'm pretty sure there are no errors in it
and
I know the code is trivial; I'm just trying to debug it with Eclipse to
prove that I can. Another UDF I wrote that also grabs the leftmost
characaters of a String works fine but it is written in style "Java" and
is therefore missing the set() method.

---------------------------------------------------------------------------------------------------------------------
public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);

set(3, leftmost);
}

---------------------------------------------------------------------------------------------------------------------
How did you register the function in your database, i.e. what's the exact
CREATE FUNCTION statement?

Sorry for the delay in replying; I spent most of yesterday trying things
that were implied by your note....

This is the definition of the leftmost() UDF function that was in effect
when I posted my question:

--------------------------------------------------------------------
CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME 'TextUDFs_Java:com.foo.java.TextUDFs.leftmost'

LANGUAGE JAVA

PARAMETER STYLE JAVA

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;

--------------------------------------------------------------------

The leftmost() function works just fine from the command line when defined
this way and I can debug it in Eclipse too; I can step through every
statement of the UDF and the driver. Naturally, the method is defined
somewhat differently than shown in my original post though; this is the
source code for leftmost(), as written for parameter style Java, stripped
to its bare bones:

--------------------------------------------------------------------------------------------------------------------- public static String leftmost(String input, int size) throws
SQLException {

try {
String trimmedInput = input.trim();
if (trimmedInput.length() < size) size =
trimmedInput.length(); String output =
trimmedInput.substring(0, size); return (output);
} catch (Exception excp) {
throw new SQLException("leftmost() - " + excp.getMessage(),
"38600");
}
---------------------------------------------------------------------------------------------------------------------

However, when I use the code shown in the first post of this thread and I
replace the definition of the leftmost() function with this:

--------------------------------------------------------------------

CREATE FUNCTION leftmost (varchar(4000), int)
RETURNS varchar(4000)
SPECIFIC leftmost
EXTERNAL NAME 'TextUDFs_DB2General:com.foo.db2general.TextUDFs.l eftmost'
You're using a JAR file here. Have you packaged your Java code into such a
JAR file and used the SQLJ.INSTALL_JAR procedure to load it into the
database?
LANGUAGE JAVA
PARAMETER STYLE DB2GENERAL
DETERMINISTIC
NO EXTERNAL ACTION
FENCED
RETURNS NULL ON NULL INPUT
ALLOW PARALLEL
NO DBINFO
NO SQL
NO SCRATCHPAD
NO FINAL CALL;

--------------------------------------------------------------------

I get an UnsatisfiedLinkError when I reach the set() statement at the end
of the method during debugging in Eclipse. The function still works just
fine from the command line.
You mean that you can call the SQL function in a SQL statement executed on
the command line? And it fails if you debug it through Eclipse?
Do you have any idea what I need to change in order to be able to debug my
function in Eclipse and step through all of the statements, _including_
the set()?
I don't know for sure. One guess might be that you don't have all the
necessary files/directories in the CLASSPATH.
I can always write diagnostic lines to a logging file if I have to for
debugging purposes but I'd rather just use Eclipse if that is possible. It
is considerably less cumbersome to simply step through the real code with
a good debugger than it is to add diagnostic code to my program.


Debugging UDFs and procedures is, unfortunately, not a straight forward task
due to the complex environments. I've done this quite often for C/C++ code
but not yet for Java.

What you could also do is to write a "main" function wrapper in Java that
calls your routine directly, taking DB2 out of the picture.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
May 2 '06 #4

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e3**********@lc03.rz.uni-jena.de...
Rhino wrote:

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e2**********@lc03.rz.uni-jena.de...
Rhino wrote:

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 db2jcc.jar are visible on my
classpath and each of them contain the COM.ibm.db2.app.UDF class with a
variety of set() methods, including the one that I am trying to
execute.
I've also tried removing db2java.zip from the classpath to see if that
would help prevent the error but it didn't.

Does anyone have any idea how I can solve this problem?

This is the UDF. By the way, I'm pretty sure there are no errors in it
and
I know the code is trivial; I'm just trying to debug it with Eclipse to
prove that I can. Another UDF I wrote that also grabs the leftmost
characaters of a String works fine but it is written in style "Java"
and
is therefore missing the set() method.
--------------------------------------------------------------------------------------------------------------------- public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);

set(3, leftmost);
}

---------------------------------------------------------------------------------------------------------------------
How did you register the function in your database, i.e. what's the
exact
CREATE FUNCTION statement?

Sorry for the delay in replying; I spent most of yesterday trying things
that were implied by your note....

This is the definition of the leftmost() UDF function that was in effect
when I posted my question:

--------------------------------------------------------------------
CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME 'TextUDFs_Java:com.foo.java.TextUDFs.leftmost'

LANGUAGE JAVA

PARAMETER STYLE JAVA

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;

--------------------------------------------------------------------

The leftmost() function works just fine from the command line when
defined
this way and I can debug it in Eclipse too; I can step through every
statement of the UDF and the driver. Naturally, the method is defined
somewhat differently than shown in my original post though; this is the
source code for leftmost(), as written for parameter style Java, stripped
to its bare bones:

---------------------------------------------------------------------------------------------------------------------
public static String leftmost(String input, int size) throws
SQLException {

try {
String trimmedInput = input.trim();
if (trimmedInput.length() < size) size =
trimmedInput.length(); String output =
trimmedInput.substring(0, size); return (output);
} catch (Exception excp) {
throw new SQLException("leftmost() - " + excp.getMessage(),
"38600");
}

---------------------------------------------------------------------------------------------------------------------


However, when I use the code shown in the first post of this thread and I
replace the definition of the leftmost() function with this:

--------------------------------------------------------------------

CREATE FUNCTION leftmost (varchar(4000), int)
RETURNS varchar(4000)
SPECIFIC leftmost
EXTERNAL NAME 'TextUDFs_DB2General:com.foo.db2general.TextUDFs.l eftmost'


You're using a JAR file here. Have you packaged your Java code into such
a
JAR file and used the SQLJ.INSTALL_JAR procedure to load it into the
database?
LANGUAGE JAVA
PARAMETER STYLE DB2GENERAL
DETERMINISTIC
NO EXTERNAL ACTION
FENCED
RETURNS NULL ON NULL INPUT
ALLOW PARALLEL
NO DBINFO
NO SQL
NO SCRATCHPAD
NO FINAL CALL;

--------------------------------------------------------------------

I get an UnsatisfiedLinkError when I reach the set() statement at the end
of the method during debugging in Eclipse. The function still works just
fine from the command line.


You mean that you can call the SQL function in a SQL statement executed on
the command line? And it fails if you debug it through Eclipse?

Sorry for the delay in responding. I checked for a reply from you several
times over the days after I last posted to this thread but after several
attempts there was no reply so I thought the thread had died. I finally
checked again a minute ago and now I see that you must have replied just
after I gave up on hearing from you. I'm not sure if you'll see this reply;
you've probably given up on ME by now!

Okay, now back to the problem. Yes, I can call the SQL function in an SQL
statement executed on the command line but it fails on the set() method if I
debug it through Eclipse.
Do you have any idea what I need to change in order to be able to debug
my
function in Eclipse and step through all of the statements, _including_
the set()?


I don't know for sure. One guess might be that you don't have all the
necessary files/directories in the CLASSPATH.

Do you have any idea what files/directories need to be on the CLASSPATH for
this to work? UnsatisfiedLinkError suggests a missing DLL but I have no idea
what DLL it is looking for; whoever did the error handling code for this
class didn't see fit to identify whatever was missing in the error message.
I can always write diagnostic lines to a logging file if I have to for
debugging purposes but I'd rather just use Eclipse if that is possible.
It
is considerably less cumbersome to simply step through the real code with
a good debugger than it is to add diagnostic code to my program.


Debugging UDFs and procedures is, unfortunately, not a straight forward
task
due to the complex environments. I've done this quite often for C/C++
code
but not yet for Java.

What you could also do is to write a "main" function wrapper in Java that
calls your routine directly, taking DB2 out of the picture.

Actually, that's what I was trying to do when I encountered this problem.

I've tried a couple of times over the years to get the IBM Distributed
Debugger to work with stored procedures - I assume it works with UDFs too
but I'm not sure - but I could never get it to work. When I posted to this
newsgroup about the problems I was having, the responses I got never helped
me enough to get that debugger working.

On March 1 2005, I posted about something I'd seen in the manuals which
suggested a way to debug a UDF with a driver program; I asked for details on
what that driver would need to contain. After getting some general remarks,
I posted my best guess on what the driver needed and you jumped in to
suggest a much simpler driver.

Two weeks ago, I had an offline enquiry from someone who'd seen that thread
and wondered if I ever got Eclipse to debug my UDF successfully. Frankly,
I'd forgotten about the whole matter so I started looking at my code from
last year and reviewed the thread and your reply.

I found that I could debug Parameter Style Java UDFs fine but got the
UnsatisfiedLinkError when I got to the set() method in the Parameter Style
DB2General UDFs. So I started this thread to see if I could get some help to
figure out the problem.

Here are the relevant parts of the Driver program. (I'm running DB2 V8.2.1
these days, not V7.2):

---------------------------------------------------------------------------------------------------------------------

import java.sql.SQLException;

public class UdfDriverV8 {

public static void main(String[] args) {

new UdfDriverV8();
}

public UdfDriverV8(); {

testLeftmost_Java();
testLeftmost_DB2General();
}

public void testLeftmost_Java() {

System.out.println("\nUDF: leftmost()");

String input = "abcdefghijk";
System.out.println(" Input String: " + input);
int size = 3;
System.out.println(" Characters to return: " + size);

String output = null;
try {
output = com.foo.db2v8.udf.java.TextUDFs.leftmost(input, size);
} catch (SQLException sql_excp) {
System.err.println("UdfDriverV8 caught SQLException. Message: "
+ sql_excp.getMessage());
sql_excp.printStackTrace();
}

System.out.println(" Output String: " + output);
}

public void testLeftmost_DB2General() {

System.out.println("\nUDF: leftmost()");

String input = "abcdefghijk";
System.out.println(" Input String: " + input);
int size = 3;
System.out.println(" Characters to return: " + size);

String output = null;
try {
com.foo.db2v8.db2general.TextUDFs textUDFs = new
com.foo.db2v8.db2general.TextUDFs();
textUDFs.leftmost(input, size, output);
} catch (Exception excp) {
System.err.println("UdfDriverV8 caught Exception. Message: " +
excp.getMessage());
excp.printStackTrace();
}

System.out.println(" Output String: " + output);
}
}
---------------------------------------------------------------------------------------------------------------------

This is the code for the Parameter Style Java version of the UDF, which
works fine and can be debugged in Eclipse:

---------------------------------------------------------------------------------------------------------------------
package com.foo.db2v8.udf.java;

public class TextUDFs extends UDF {

public static String leftmost(String input, int size) throws
SQLException {

try {
String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String output = trimmedInput.substring(0, size);
return (output);
} catch (Exception excp) {
throw new SQLException("leftmost() - " + excp.getMessage(),
"38600");
}

}
}

---------------------------------------------------------------------------------------------------------------------

This is the code for the Parameter Style DB2General version of the UDF,
which works fine and can ALMOST be debugged in Eclipse, except that I get
UnsatisfiedLinkError when I step onto the set() method:
---------------------------------------------------------------------------------------------------------------------
package come.foo.db2v8.udf.db2general;

public class TextUDFs extends UDF {

public void leftmost(String input, int size, String output) throws
Exception {

String trimmedInput = input.trim();
if (trimmedInput.length() < size) size = trimmedInput.length();
String leftmost = trimmedInput.substring(0, size);
set(3, leftmost); //UnsatisfiedLinkError on this line
}

}
---------------------------------------------------------------------------------------------------------------------

Important: All of the source code for both the driver and both versions of
the UDF compiles without any problems so Eclipse can clearly 'see'
everything it needs to compile. I only run into trouble when debugging the
DB2GENERAL UDF.

This is the CREATE FUNCTION statement for the Parameter Style Java version
of the UDF:
---------------------------------------------------------------------------------------------------------------------
CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME 'TextUDFs_Java:com.foo.db2v8.udf.java.TextUDFs.lef tmost'

LANGUAGE JAVA

PARAMETER STYLE JAVA

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;

---------------------------------------------------------------------------------------------------------------------
This is the CREATE FUNCTION statement for the Parameter Style DB2General
version of the UDF:
---------------------------------------------------------------------------------------------------------------------

CREATE FUNCTION leftmost (varchar(4000), int)

RETURNS varchar(4000)

SPECIFIC leftmost

EXTERNAL NAME
'TextUDFs_DB2General:com.foo.db2v8.udf.db2general. TextUDFs.leftmost'

LANGUAGE JAVA

PARAMETER STYLE DB2GENERAL

DETERMINISTIC

NO EXTERNAL ACTION

FENCED

RETURNS NULL ON NULL INPUT

ALLOW PARALLEL

NO DBINFO

NO SQL

NO SCRATCHPAD

NO FINAL CALL;
---------------------------------------------------------------------------------------------------------------------

Is there any other information I can provide that would help you or anyone
else figure out how to solve my UnsatisfiedLinkError?

I'm completely baffled by this problem. I have no idea what Java thinks it
is missing so I don't know how to make the missing resource available to
Eclipse. Everything compiles fine so everything Eclipse needs seems to be
available yet I get this runtime error.

--
Rhino

May 7 '06 #5
Rhino wrote:
"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e3**********@lc03.rz.uni-jena.de...
Rhino wrote:

Do you have any idea what files/directories need to be on the CLASSPATH
for this to work? UnsatisfiedLinkError suggests a missing DLL but I have
no idea what DLL it is looking for; whoever did the error handling code
for this class didn't see fit to identify whatever was missing in the
error message.


The good news is that I can reproduce the problem in Eclipse. After all,
the issue is completely unrelated to DB2, except that you try to call a
method in the UDF class.

The bad news is this: The various "set" methods (and a bunch of others) are
native Java methods. When DB2 starts a JVM, it takes care to register the
C/C++ functions that correspond to the Java methods using the proper calls
to RegisterNatives() (in the C side).

I don't know if and how you could do the registration from the Java side.
If it is possible, you still have to figure out the respective mapping.
The native implementations for the "set" methods can be found in the
"libdb2jext" library. This has to be loaded and then the method "set(int,
String)" maps to the C function sqlejNMudf_setString, for example.

This is all rather cumbersome, and my suggestion would be to not use the DB2
classes COM.ibm.db2.app.* for your purposes but rather implement your own
variations as some sort of dummy driver. Then you can write some log
information once such a method is invoked and, at the same time, you avoid
the UnsatisfiedLinkException originating from the missing library/native
function linkage.

p.s: Note that another problem is that DB2 will verify that the methods in
the UDF class are only called when a UDF invocation is underway.
Otherwise, an exception is thrown. If this would apply to your debug
scenario. I do not know for sure.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
May 10 '06 #6

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e3**********@lc03.rz.uni-jena.de...
Rhino wrote:
"Knut Stolze" <st****@de.ibm.com> wrote in message
news:e3**********@lc03.rz.uni-jena.de...
Rhino wrote:
Do you have any idea what files/directories need to be on the CLASSPATH
for this to work? UnsatisfiedLinkError suggests a missing DLL but I have
no idea what DLL it is looking for; whoever did the error handling code
for this class didn't see fit to identify whatever was missing in the
error message.


The good news is that I can reproduce the problem in Eclipse. After all,
the issue is completely unrelated to DB2, except that you try to call a
method in the UDF class.

I'm glad to hear that you duplicated my problem; at least the nature of my
problem is now clear.
The bad news is this: The various "set" methods (and a bunch of others)
are
native Java methods. When DB2 starts a JVM, it takes care to register the
C/C++ functions that correspond to the Java methods using the proper calls
to RegisterNatives() (in the C side).

I don't know if and how you could do the registration from the Java side.
If it is possible, you still have to figure out the respective mapping.
The native implementations for the "set" methods can be found in the
"libdb2jext" library. This has to be loaded and then the method "set(int,
String)" maps to the C function sqlejNMudf_setString, for example.

This is all rather cumbersome, and my suggestion would be to not use the
DB2
classes COM.ibm.db2.app.* for your purposes but rather implement your own
variations as some sort of dummy driver. Then you can write some log
information once such a method is invoked and, at the same time, you avoid
the UnsatisfiedLinkException originating from the missing library/native
function linkage.

p.s: Note that another problem is that DB2 will verify that the methods in
the UDF class are only called when a UDF invocation is underway.
Otherwise, an exception is thrown. If this would apply to your debug
scenario. I do not know for sure.

Thank you for all your efforts in understanding and explaining why this
approach is so problematic!

It is very disappointing that this approach will not work nearly as easily
as it first appeared but at least I have an idea on how it can be done now.
I doubt that I will take either approach - doing my own registrations of the
native functions or writing dummy drivers - but at least these are options
if I really get stuck on debugging my UDFs. Registering the native functions
myself looks like it will take considerable time and will require me to buy
an expensive C/C++ compiler. Writing dummy functions to prevent the link
error is likely to be a lot of work too since there are many functions.

It's easier to stay with my old approach of writing lines to a simple log
file and debuggng my UDFs and stored procedures that way. It's not as slick
as using a modern debugger but it works fine without having to do all the
work implied by registering all those functions or writing dummy functions.

Or maybe I'll try once again to get the IBM Distributed Debugger to run
correctly for me, although that would be a lot more tempting if I could
actually get free support for it somewhere.

I wish I knew how to persuade IBM to provide friendlier ways of debugging
UDFs and stored procedures in modern debuggers!

Again, thanks for your help with this, Knut!

--
Rhino
May 10 '06 #7

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

Similar topics

0
by: Phillip Montgomery | last post by:
Hello all; I'm trying to debug an issue with a java script called, SelectSockets. It appears to be a fairly common one found on the web. I downloaded the SGI Java v1.4.1 installation from SGI's...
0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
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...
1
by: Akaketwa | last post by:
i have an application deployed on WAS6.0 that uses a db2 v8.1 database on a linux platform. when i try to run it i get a java.lang.UnsatisfiedLinkError:SQLConnect error. i have tried some solution...
1
by: GayatriS | last post by:
Hi, I have written a jni program to call my vc++ dll. My java program is as below: //CODE import java.util.*; class callVcc { native int sum(int i, int j);
3
by: Jazi | last post by:
Hi, I have built a web servise using JNI under jboss. The JNI loads a native library static { Ststem.loadLibrary("foo"); } If I starts the jboss server then I do not have any issue...
2
by: ycinar | last post by:
Hello, i have a java project which builds fine but when i come to run it the following error is displayed: java.lang.UnsatisfiedLinkError: no FileSystemDll in...
1
Ganesh9u
by: Ganesh9u | last post by:
Hi All, import org.sf.feeling.swt.win32.extension.hook.Hook; import org.sf.feeling.swt.win32.extension.hook.data.HookData; import org.sf.feeling.swt.win32.extension.hook.data.MouseHookData; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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
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
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.