Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2002
    Posts
    3

    Unanswered: Problem in Java UDF

    Hello,

    I am trying to write a java UDF in DB2 version 7. I used the following command to register the stored procedure.

    create function mailer() returns varchar(70) fenced variant no sql external action language java parameter style java external name 'GenXML!myXML'

    This command executed properly. The GenXML.java file is -

    public class GenXML extends UDF {
    public static String myXML()
    {
    String temp = "ABC";
    return temp;
    }
    }


    I compiled this file and placed the GenXML.class in the c:\Progra~1\SQLLIB\function\ directory. I am using Windows NT.
    When I execute the sql command

    select mailer() from db2admin.temp

    the following error is flagged -
    SQL4304N Java stored procedure or user-defined function
    "ADMINISTRATOR.MAILER", specific name "SQL020822230051877" could not load Java
    class "GenXML", reason code "1". SQLSTATE=42724

    It appears that db2 is unable to locate the class file. Where do I need to place the class file to rectify the error ? Or am I going wrong somewhere else ?

    Regards,
    Manish

  2. #2
    Join Date
    Feb 2002
    Location
    Germany
    Posts
    141
    Hi,

    Try to check the following:
    select * from sysibm.sysfunctions
    where name = 'MAILER'

    look at the column "SCHEMA"

    and check if this schema is in your function path

    select current path from sysibm.sysdummy1

    Hope it helps,
    Rodney Krick

  3. #3
    Join Date
    Aug 2002
    Posts
    3
    Thanks Rodney

    The schema is "Administrator" and it is in the current path.
    I am using JDK 1.4. I found out that db2 has support only for jdk1.1 and jdk1.2 I installed jdk1.2.2 But still the same error was flagged.

    Manish

    Originally posted by RKrick
    Hi,

    Try to check the following:
    select * from sysibm.sysfunctions
    where name = 'MAILER'

    look at the column "SCHEMA"

    and check if this schema is in your function path

    select current path from sysibm.sysdummy1

    Hope it helps,

  4. #4
    Join Date
    Aug 2002
    Location
    Sacramento, CA
    Posts
    2
    Try this:

    public class GenXML extends UDF {
    public void myXML(String returnXml)
    {
    String temp = "ABC";
    set(1,temp);
    }
    }

    I think your create function call is correct for a class defined like this. Give that a try and see what happens.

  5. #5
    Join Date
    Aug 2002
    Posts
    3
    Thanks all !

    My problem got sorted. When I switched from java 1.4 to java 1.1.8 I had not recompiled the java file. Hence db2 (which is compatibly only with java 1.1 and 1.2) was unable to load the class file.

    Manish

    Originally posted by sethaniel
    Try this:

    public class GenXML extends UDF {
    public void myXML(String returnXml)
    {
    String temp = "ABC";
    set(1,temp);
    }
    }

    I think your create function call is correct for a class defined like this. Give that a try and see what happens.

Posting Permissions

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