By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,924 Members | 1,651 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,924 IT Pros & Developers. It's quick & easy.

JAVA UDF Accessing Another static class

P: n/a
Jae
Hello, here's what I want to do but I'm not sure if it will work
because Im not sure how DB2 works with the JVM.

Heres my setup:

DB2---->UDF Class (lets call it A)----->Static Class (Lets call it B)

I have a class that contains some UDFs. I want these UDFs to call
static methods on class B. Its very important that the static
variables in class B is *NEVER* reset. I understand that on each
statement class A will have a new object instantiated. Will DB2 ever
reset the static data in class B?

Thanks in advance

Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jae wrote:
Hello, here's what I want to do but I'm not sure if it will work
because Im not sure how DB2 works with the JVM.

Heres my setup:

DB2---->UDF Class (lets call it A)----->Static Class (Lets call it B)

I have a class that contains some UDFs. I want these UDFs to call
static methods on class B. Its very important that the static
variables in class B is *NEVER* reset. I understand that on each
statement class A will have a new object instantiated. Will DB2 ever
reset the static data in class B?


DB2 uses a specialized Java class loader to ensure that each connection is
separated from all others. (That's the "isolation" concept in the ACID
properties of transactions.) So upon the first invocation, the JVM creates
the static object of class B _for the current connection_. Another
connection will have another object of class B!

The static objects themselves live as long as the JVM is running. I don't
think DB2 will shut the JVM down, unless DB2 itself is shut down. So the
answer to your question is that the static objects are not destroyed
("reset" is hardly the right term, is it?).

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #2

P: n/a
DB2 may (or may not) unload a class at any time that it's not in use by
a transaction. You can't rely on the state of an object after the
transaction using the udf that loaded the object completes. DB2 may also
choose to run a new instance of the java method on a new JVM (depending
on a threaded jvms heap usage).

Knut Stolze wrote:
Jae wrote:

Hello, here's what I want to do but I'm not sure if it will work
because Im not sure how DB2 works with the JVM.

Heres my setup:

DB2---->UDF Class (lets call it A)----->Static Class (Lets call it B)

I have a class that contains some UDFs. I want these UDFs to call
static methods on class B. Its very important that the static
variables in class B is *NEVER* reset. I understand that on each
statement class A will have a new object instantiated. Will DB2 ever
reset the static data in class B?

DB2 uses a specialized Java class loader to ensure that each connection is
separated from all others. (That's the "isolation" concept in the ACID
properties of transactions.) So upon the first invocation, the JVM creates
the static object of class B _for the current connection_. Another
connection will have another object of class B!

The static objects themselves live as long as the JVM is running. I don't
think DB2 will shut the JVM down, unless DB2 itself is shut down. So the
answer to your question is that the static objects are not destroyed
("reset" is hardly the right term, is it?).

Nov 12 '05 #3

P: n/a
Sean McKeough wrote:
DB2 may (or may not) unload a class at any time that it's not in use by
a transaction. You can't rely on the state of an object after the
transaction using the udf that loaded the object completes. DB2 may also
choose to run a new instance of the java method on a new JVM (depending
on a threaded jvms heap usage).

Knut Stolze wrote:
Jae wrote:

Hello, here's what I want to do but I'm not sure if it will work
because Im not sure how DB2 works with the JVM.

Heres my setup:

DB2---->UDF Class (lets call it A)----->Static Class (Lets call it B)

I have a class that contains some UDFs. I want these UDFs to call
static methods on class B. Its very important that the static
variables in class B is *NEVER* reset. I understand that on each
statement class A will have a new object instantiated. Will DB2 ever
reset the static data in class B?

DB2 uses a specialized Java class loader to ensure that each connection
is
separated from all others. (That's the "isolation" concept in the ACID
properties of transactions.) So upon the first invocation, the JVM
creates
the static object of class B _for the current connection_. Another
connection will have another object of class B!

The static objects themselves live as long as the JVM is running. I
don't
think DB2 will shut the JVM down, unless DB2 itself is shut down. So the
answer to your question is that the static objects are not destroyed
("reset" is hardly the right term, is it?).


In addition to Sean's explanations, you might want to adapt your design in
such a way that the global/static objects are written to disk when they are
destroyed. That way you can preserve the information and reload it again
when a new static object is created.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.