If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > UDF in JAVA update problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-04, 04:42
MoeliTec MoeliTec is offline
Registered User
 
Join Date: Nov 2003
Location: Belgium
Posts: 12
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?
Reply With Quote
  #2 (permalink)  
Old 01-29-04, 09:18
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: UDF in JAVA update problem

Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 02-25-04, 07:24
MoeliTec MoeliTec is offline
Registered User
 
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?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On