Dear all smart experts,
I write a simple Java UDF, which should run on DB2 v8 on AIX. But it can't load the Java class. Help ugently needed!! Thanks!
I develop and deploy the Java UDF with these steps:
1. Write the java class, compile and make a jar (see below for source).
2. Call SQLJ.REPLACE_JAR ('file:/home/pws01ta/pws01ta1/examples.jar','test',0)
3. call sqlj.refresh_classes()
4. Create the function by running "create function properties() returns table (property varchar(500), value varchar(500)) external name 'test:com.hase.JVMProperties!dump' language java parameter style db2general fenced no sql disallow parallel scratchpad"
Everything seems ok but when I run the SQL "select * from table (properties()) as t", I got:
SQL4304N Java stored procedure or user-defined function "PWS01TA1.PROPERTIES",
specific name "SQL070118203908600" could not load Java class
"com/hase/JVMProperties", reason code "1". SQLSTATE=42724
This is the source code of the java class:
package com.hase;
import COM.ibm.db2.app.*;
import java.util.*;
public class JVMProperties extends UDF {
Enumeration propertyNames;
Properties properties ;
public void dump (String property, String value) throws Exception
{
int callType = getCallType();
switch(callType) {
case SQLUDF_TF_FIRST:
break;
case SQLUDF_TF_OPEN:
properties = System.getProperties();
propertyNames = properties.propertyNames();
break;
case SQLUDF_TF_FETCH:
if (propertyNames.hasMoreElements()) {
property = (String) propertyNames.nextElement();
value = properties.getProperty(property);
set(1, property);
set(2, value);
} else {
setSQLstate("02000");
}
break;
case SQLUDF_TF_CLOSE:
break;
case SQLUDF_TF_FINAL:
break;
default:
throw new Exception("UNEXPECT call type of "+callType);
}
}
}