Enuda
asked on
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_RECO RD
WHERE NM_FRST = 'SKYLER';
SQL4304N Java stored procedure or user-defined function "DB2ADMIN.DMPHONEJAVASCALA R", 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.DMPHONEJAVASCALA R", 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.StoredPr oc" 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
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
from FSNST201.BR_DOH_BIRTH_RECO
WHERE NM_FRST = 'SKYLER';
SQL4304N Java stored procedure or user-defined function "DB2ADMIN.DMPHONEJAVASCALA
SQL4304N Java stored procedure or user-defined function "DB2ADMIN.DMPHONEJAVASCALA
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.StoredPr
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your response. I'm sure I will be reading more of java docs in the future. Right now I find myself in a position of doing it first, and learn later!
(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/jav
params="-Djava.home=/usr/l
clp="$CLASSPATH:/usr/share
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 take a look.
problem is just coping the jar files / class files of your java code to the jdbc driver directory, because it is in the CLASSPATH. the jdbc driver under AIX if i'm not mistaken will be
/home/db2inst1/sqllib/java
On error item #2, how can I find out if a class did or did not implement the required interface ("COM.ibm.db2.app.StoredPr
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".
5 Could not establish default context. What could this be or mean?
momi_sabaq, I trully appreciate your continuing effort to help with this problem.
Thanks
Open in new window