Question : UDF unable to load Java class. What do I need to do to make this work?

Hello all,
Continuing my UDF adventure started two days ago, 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:
                SQL
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

SQL4304N  Java stored procedure or user-defined function "DB2ADMIN.DMPHONEJAVASCALAR", specific name "DMPHONEJAVASCALAR" could not load Java class "/home/db2inst1/sqllib/fun", reason code "".

Explanation:
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.  

User Response:

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
SQLCODE: -4304

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.
I fyou any question that you need answered please do not hesitate to ask as I will be monitoring this forum for the best part of this evening.

Thanks

Enuda
   

Answer : UDF unable to load Java class. What do I need to do to make this work?

hi
i don't understand what is the code you have attached
can you try to put your classes under /home/db2inst1/sqllib/java ? i

regarding - 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?

who wrote the java code ? if you wrote it, you need to know if you have implemented the specified interfaces, and regarding the PUblic flag, i believe it means your class should be declared as public
i think you can look at example under the /sqllib/sample/java diectory

Random Solutions  
 
programming4us programming4us