Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    12

    Unanswered: UDF in JAVA update problem

    I'm using DB2 v8.1 on Linux.
    I'm busy writing UDF's in Java.
    Following things works fine:
    I make a class-file put in the folder sqllib/function, excecute the query:
    CREATE FUNCTION test(a Int) RETURNS Int EXTERNAL NAME 'udfs.multiply' LANGUAGE JAVA PARAMETER STYLE java NO SQL

    When I test the function, he does what I expect it to do, so far no problem, but when I want to change the class file to update the function, just replacing te class file in the sqllib/function directory is not enough. Even when I drop the function test and create it again, he stills works with the function written in the first created class-file.
    When I stop the database (db2stop) and start it again, and then create the function test again, then he takes the updated function in the new class file, but I don't like thus method.
    How can I become the same result, without having to restart the database?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: UDF in JAVA update problem

    Originally posted by MoeliTec
    I'm using DB2 v8.1 on Linux.
    I'm busy writing UDF's in Java.
    Following things works fine:
    I make a class-file put in the folder sqllib/function, excecute the query:
    CREATE FUNCTION test(a Int) RETURNS Int EXTERNAL NAME 'udfs.multiply' LANGUAGE JAVA PARAMETER STYLE java NO SQL

    When I test the function, he does what I expect it to do, so far no problem, but when I want to change the class file to update the function, just replacing te class file in the sqllib/function directory is not enough. Even when I drop the function test and create it again, he stills works with the function written in the first created class-file.
    When I stop the database (db2stop) and start it again, and then create the function test again, then he takes the updated function in the new class file, but I don't like thus method.
    How can I become the same result, without having to restart the database?
    I suggest you read the Application Development Guide for DB2 (you can find it on the IBM web site). It explains in detail (see Chapter 21) how to build and install Java stored procedures and UDFs.

    In short, to be able to dynamically replace loaded classes you should deploy them as a .jar file and use INSTALL_JAR/REPLACE_JAR functions to... well, install or replace classess.

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    12
    Working with jar's instead was indeed the solution, but the REPLACE_JAR doesn't work.
    The way to get it to work is as follows:

    call sqlj.refresh_classes(void)
    call sqlj.remove_jar('myjarke')
    call sqlj.refresh_classes(void)
    call sqlj.install_jar('file:/.../myudfjar.jar', 'myjarke' )
    call sqlj.refresh_classes(void)

    But wich ' Application Development Guide for DB2' is ment, cause none of the 3 I find on the site has 21 chapters?

Posting Permissions

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