Right now I find myself in a position of doing it first, and learn setting up Java UDF later!
I have managed to get the UDF registered but having problem getting the Java code to work. I need assistance to get this Double Metaphone Java UDF to work pretty quickly. Here is what I tried to run and the error
message that resulted:
select nm_frst, NM_LST, DB2ADMIN.DMPHONEJAVASCALAR(NM_LST)
from FSNST201.BR_DOH_BIRTH_RECORD WHERE NM_FRST = 'SKYLER';
SQL4304N Java stored procedure or user-defined function
"DB2ADMIN.DMPHONEJAVASCALAR", specific name "DMPHONEJAVASCALAR" could not load Java class
"/home/db2inst1/sqllib/fun", reason code "". SQLSTATE=42724
The Java class given by the EXTERNAL NAME clause of a CREATE PROCEDURE or CREATE FUNCTION statement could not be loaded. The reason codes are:
1 The class was not found on the CLASSPATH.
2 The class did not implement the required interface ("COM.ibm.db2.app.StoredProc" or "COM.ibm.db2.app.UDF")
or lacked the Java "public" access flag.
3 The default constructor failed or was unavailable.
4 Could not load driver for "jdbc:default:connection".
5 Could not establish default context.
Ensure that the compiled ".class" file is installed in the CLASSPATH, for example under "sqllib/function".
Ensure it implements the required Java interfaces and is "public".
sqlcode : -4304
sqlstate : 42724
I will appreciate it if someone can guide me to determine if at all I am properly set up to invoke a javaUDF, What do I need to look for, and how I can go about setting up my environment and the UDF to execute successfully.
Okay, here are my questions based on the error above:
(1) Yes, db2inst1 runs the instance. First, the CLASSPATH. I tried to find it using the command "Which java" and got "/usr/bin/java" which is supposed to be my java home. Is this the same as CLASSPATH? When I looked in this directory, I found this "java ---->/etc/alternatives/java". So I navigated to this path, found and once again I found this "java -> /usr/lib/jvm/jre-1.4.2-gcj/bin/java". Once again, I navigated to this directory and found two scripts named "java" and "rmiregistry". I browsed the member called java and found this in the script the following lines that was of interest:
The above seem to point to the real classpath, right? How can I be sure of this? As I said, there are only the two members above in this dirctory. Nothing else. I have attached the actual java code as I have it. Please ake a look.
On error item #2, how can I find out if a class did or did not implement the required interface
("COM.ibm.db2.app.StoredProc" or "COM.ibm.db2.app.UDF") or lacked the Java "public" access flag.? Is there any config or init file that I can look into to find out? Any environment variable?
3 The default constructor failed or was unavailable. What is this? How can I tell if it is available? Is this a system code or microcode of some sort?
4 Could not load driver for "jdbc:default:connection". Now, drivers I can understand but don't know how to find out if it is available and loaded at startup. Anyway to find out?
5 Could not establish default context. What could this be or mean?
Thanks in advance everyone who wishes to help.
January 31, 2008 8:37 PM