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_JA R ('file:/home/pws01ta/pws01ta1/examples.jar',' test',0)
3. call sqlj.refresh_cl asses()
4. Create the function by running "create function properties() returns table (property varchar(500), value varchar(500)) external name 'test:com.hase. JVMProperties!d ump' 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.PROPE RTIES",
specific name "SQL07011820390 8600" 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.getPrope rties();
propertyNames = properties.prop ertyNames();
break;
case SQLUDF_TF_FETCH :
if (propertyNames. hasMoreElements ()) {
property = (String) propertyNames.n extElement();
value = properties.getP roperty(propert y);
set(1, property);
set(2, value);
} else {
setSQLstate("02 000");
}
break;
case SQLUDF_TF_CLOSE :
break;
case SQLUDF_TF_FINAL :
break;
default:
throw new Exception("UNEX PECT call type of "+callType) ;
}
}
}
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_JA R ('file:/home/pws01ta/pws01ta1/examples.jar',' test',0)
3. call sqlj.refresh_cl asses()
4. Create the function by running "create function properties() returns table (property varchar(500), value varchar(500)) external name 'test:com.hase. JVMProperties!d ump' 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.PROPE RTIES",
specific name "SQL07011820390 8600" 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.getPrope rties();
propertyNames = properties.prop ertyNames();
break;
case SQLUDF_TF_FETCH :
if (propertyNames. hasMoreElements ()) {
property = (String) propertyNames.n extElement();
value = properties.getP roperty(propert y);
set(1, property);
set(2, value);
} else {
setSQLstate("02 000");
}
break;
case SQLUDF_TF_CLOSE :
break;
case SQLUDF_TF_FINAL :
break;
default:
throw new Exception("UNEX PECT call type of "+callType) ;
}
}
}
Comment