473,382 Members | 1,332 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,382 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 2032
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.