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

Java UDF Question

I am writing Java UDFs using DB2 V8.2 (Fixpack 8) on Windows XP.

I would like to create some common code classes that are visible to the UDFs
on my system but I'm not having a lot of luck so far. I'm wondering if I'm
trying to do the impossible or if my technique is just wrong.

One of the common code classes I want to write contains code to open, write
and close a flat file that can be used for debugging. I'd like that class to
be visible to all of my Java UDFs so that I don't have to duplicate that
code in each and every Java UDF.

However, before I go that far, I decided to make a simple class that is
accessible to a Java class containing a UDF. I compiled it and then put the
resulting .class file in c:\Program Files\IBM\SQLLIB\FUNCTION, hoping that
my UDF would see it. However, when I execute the UDF that is supposed to use
it, the UDF fails on a NoClassDefFoundError.

(The UDF itself is in a Jar file at c:\Program
Files\IBM\SQLLIB\FUNCTION\jar\RHINO but that didn't seem the right place to
put a standalone class. However, when I tried copying my common code .class
file there anyway, the UDF failed on the exact same error.)

So, have I simply put the .class file in the wrong place? If so, where is
the right place?

Or is it simply not possible for the UDF to see any class other than itself?
In this case, I will have to duplicate my common code in every UDF that
needs debugging capability, which seems very redundant.

I can't find anything in the manuals that specifically says that a Java UDF
can or cannot see anything outside its own class.

--
Rhino
Nov 12 '05 #1
6 2024
Rhino wrote:
I am writing Java UDFs using DB2 V8.2 (Fixpack 8) on Windows XP.

I would like to create some common code classes that are visible to the
UDFs on my system but I'm not having a lot of luck so far. I'm wondering
if I'm trying to do the impossible or if my technique is just wrong.

One of the common code classes I want to write contains code to open,
write and close a flat file that can be used for debugging. I'd like that
class to be visible to all of my Java UDFs so that I don't have to
duplicate that code in each and every Java UDF.

However, before I go that far, I decided to make a simple class that is
accessible to a Java class containing a UDF. I compiled it and then put
the resulting .class file in c:\Program Files\IBM\SQLLIB\FUNCTION, hoping
that my UDF would see it. However, when I execute the UDF that is supposed
to use it, the UDF fails on a NoClassDefFoundError.

(The UDF itself is in a Jar file at c:\Program
Files\IBM\SQLLIB\FUNCTION\jar\RHINO but that didn't seem the right place
to put a standalone class. However, when I tried copying my common code
.class file there anyway, the UDF failed on the exact same error.)

So, have I simply put the .class file in the wrong place? If so, where is
the right place?

Or is it simply not possible for the UDF to see any class other than
itself? In this case, I will have to duplicate my common code in every UDF
that needs debugging capability, which seems very redundant.

I can't find anything in the manuals that specifically says that a Java
UDF can or cannot see anything outside its own class.


Java UDFs are just like any other Java program (except that the entry point
is not "main" but rather the method specified in the CREATE FUNCTION
statement). Per default, sqllib/function/ is in the classpath with which
the JVM is started by DB2. I had several situations where I had a series
of classes in the sqllib/function/ directory (each in their own .class
file) and they did work together quite nicely.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #2
Is sqllib\function on the system classpath? As long as the class is on
the system classpath, db2 should be able to find it. Note that the
entire instance share a single classpath and that might cause problem
if you have the same class file in various paths. A more customizable
classpath for each java routien is probably something DB2 should
implement in the future.

Nov 12 '05 #3

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:d1**********@fsuj29.rz.uni-jena.de...
Rhino wrote:
I am writing Java UDFs using DB2 V8.2 (Fixpack 8) on Windows XP.

I would like to create some common code classes that are visible to the
UDFs on my system but I'm not having a lot of luck so far. I'm wondering
if I'm trying to do the impossible or if my technique is just wrong.

One of the common code classes I want to write contains code to open,
write and close a flat file that can be used for debugging. I'd like that class to be visible to all of my Java UDFs so that I don't have to
duplicate that code in each and every Java UDF.

However, before I go that far, I decided to make a simple class that is
accessible to a Java class containing a UDF. I compiled it and then put
the resulting .class file in c:\Program Files\IBM\SQLLIB\FUNCTION, hoping that my UDF would see it. However, when I execute the UDF that is supposed to use it, the UDF fails on a NoClassDefFoundError.

(The UDF itself is in a Jar file at c:\Program
Files\IBM\SQLLIB\FUNCTION\jar\RHINO but that didn't seem the right place
to put a standalone class. However, when I tried copying my common code
.class file there anyway, the UDF failed on the exact same error.)

So, have I simply put the .class file in the wrong place? If so, where is the right place?

Or is it simply not possible for the UDF to see any class other than
itself? In this case, I will have to duplicate my common code in every UDF that needs debugging capability, which seems very redundant.

I can't find anything in the manuals that specifically says that a Java
UDF can or cannot see anything outside its own class.
Java UDFs are just like any other Java program (except that the entry

point is not "main" but rather the method specified in the CREATE FUNCTION
statement). Per default, sqllib/function/ is in the classpath with which
the JVM is started by DB2. I had several situations where I had a series
of classes in the sqllib/function/ directory (each in their own .class
file) and they did work together quite nicely.

You haven't quite answered my question, probably because I didn't explain it
clearly enough.

If I define a Java class Foo, *which is NOT a Java UDF itself*, compile it
and put the .class file in sqllib/function, should a Java UDF be able to see
it? I'd like to be able to execute the methods in Foo from a Java UDF.

In other words, Foo is just a regular Java class and is *not* a UDF so no
CREATE FUNCTION was ever executed for it.

This is the situation I am trying to create but it isn't working. I'm
wondering if it is possible. If it is possible, I don't understand why my
UDF is not seeing the class when the UDF executes since I put the .class
file in sqllib/function.

Rhino
Nov 12 '05 #4

"W Gemini" <wg*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Is sqllib\function on the system classpath?
Yes it is.
As long as the class is on
the system classpath, db2 should be able to find it.
Any idea why my non-UDF class isn't being found? I'm wondering if a UDF is
unable to see a class other than itself? Or maybe having a mix of classes in
jars (in sqllib/function/jar/schema) and standalone classes (in
sqllib/function) is causing problems?
Note that the
entire instance share a single classpath and that might cause problem
if you have the same class file in various paths. A more customizable
classpath for each java routien is probably something DB2 should
implement in the future.

I'm not sure that would be better ;-) I suspect that one customizable
classpath for the whole instance is better than having several customizable
classpaths. In the first scenario, at least it is obvious what the classpath
is; in the second scenario you'd never quite be sure which classpath is in
effect.

Rhino
Nov 12 '05 #5
Rhino wrote:
Java UDFs are just like any other Java program (except that the entry
point
is not "main" but rather the method specified in the CREATE FUNCTION
statement). Per default, sqllib/function/ is in the classpath with which
the JVM is started by DB2. I had several situations where I had a series
of classes in the sqllib/function/ directory (each in their own .class
file) and they did work together quite nicely.
You haven't quite answered my question, probably because I didn't explain
it clearly enough.

If I define a Java class Foo, *which is NOT a Java UDF itself*, compile it
and put the .class file in sqllib/function, should a Java UDF be able to
see it? I'd like to be able to execute the methods in Foo from a Java UDF.

In other words, Foo is just a regular Java class and is *not* a UDF so no
CREATE FUNCTION was ever executed for it.


What I meant is that from a Java/JVM perspective, there is absolutely
nothing special about Java UDFs that get called by the DB2 engine. A Java
UDF is like any other Java program. A Java program can invoke methods from
other classes, and so can a Java UDF. There is nothing in DB2 to prevent
you from calling methods of other classes.
This is the situation I am trying to create but it isn't working. I'm
wondering if it is possible. If it is possible, I don't understand why my
UDF is not seeing the class when the UDF executes since I put the .class
file in sqllib/function.


Something in your setup is amiss, I'd say. You should have a look at your
CLASSPATH that is available inside the UDF, i.e. what is the
java.class.path property set to? DB2 adds a few paths to the path set in
your enviroment.

The first result on google gave the V7 documentation, but you should also
find some relevant information there:
http://publib.boulder.ibm.com/infoce...0/db2a0162.htm

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #6

"Knut Stolze" <st****@de.ibm.com> wrote in message
news:d1**********@fsuj29.rz.uni-jena.de...
Rhino wrote:
Java UDFs are just like any other Java program (except that the entry
point
is not "main" but rather the method specified in the CREATE FUNCTION
statement). Per default, sqllib/function/ is in the classpath with which the JVM is started by DB2. I had several situations where I had a series of classes in the sqllib/function/ directory (each in their own .class
file) and they did work together quite nicely.
You haven't quite answered my question, probably because I didn't explain it clearly enough.

If I define a Java class Foo, *which is NOT a Java UDF itself*, compile it and put the .class file in sqllib/function, should a Java UDF be able to
see it? I'd like to be able to execute the methods in Foo from a Java UDF.
In other words, Foo is just a regular Java class and is *not* a UDF so no CREATE FUNCTION was ever executed for it.


What I meant is that from a Java/JVM perspective, there is absolutely
nothing special about Java UDFs that get called by the DB2 engine. A Java
UDF is like any other Java program. A Java program can invoke methods

from other classes, and so can a Java UDF. There is nothing in DB2 to prevent
you from calling methods of other classes.
Excellent! That is exactly what I was hoping to hear. Now I know that it is
only my setup that has a problem, not that the whole thing is impossible
from the start.
This is the situation I am trying to create but it isn't working. I'm
wondering if it is possible. If it is possible, I don't understand why my UDF is not seeing the class when the UDF executes since I put the .class
file in sqllib/function.


Something in your setup is amiss, I'd say. You should have a look at your
CLASSPATH that is available inside the UDF, i.e. what is the
java.class.path property set to? DB2 adds a few paths to the path set in
your enviroment.

The first result on google gave the V7 documentation, but you should also
find some relevant information there:

http://publib.boulder.ibm.com/infoce...0/db2a0162.htm

Thank you! Now I should be able to sort out the problem.

Rhino
Nov 12 '05 #7

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

Similar topics

28
by: gmcdanie | last post by:
I am looking for a Java Decompiler... preferably free. Any suggestions. Ease of use isn't a problem as long as it does a fair job.
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...
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
9
by: babylon | last post by:
i just read this (http://java.sun.com/developer/technicalArticles/releases/j2se15/) am I correcting on these concepts? Java Metadata == C# Attribute (java learn from c#?) Java Generics == C#...
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...
15
by: himilecyclist | last post by:
My State government organization has written a PHP/MySQL application which has been in production for about 6 months and has been highly successful. We are now embarking on a similar database...
0
by: Aaron J. Margosis | last post by:
I'm not a Java programmer, but I'm trying to solve some application compatibility issues with locked down security settings on Windows. My question: How do different Java-delivery tools invoke...
63
by: s0suk3 | last post by:
I've been programming Python for a couple of years now. Now I'm looking to move on to either C++ or Java, but I'm not sure which. Which one do you think will be a better transition for a Python...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.