Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2007
    Posts
    5

    Unanswered: Can't load java class of Java UDF

    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);
    }
    }
    }

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Argument lists of your UDF and the Java method don't match - I think that might be the reason.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jan 2007
    Posts
    5
    The parameters to dump method are not input parameters of the functions...

    I tried the samples UDFsqlsv.java from IBM. It does not work too.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    The parameters are fine. What do you have in the diag.log for the function call? There will be some additional information.

    Have you tried the same things without JAR files?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •