473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

JAVA UDF Accessing Another static class

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
3 1599
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Generic Usenet Account | last post by:
I am trying to create a Java application that reads a list of URLs from a file and stores their contents on the local file system. I have succeeded in accessing normal websites, but I am unable to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
0
by: VeeraLakshmi | last post by:
I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.We are giving access rights as allow or deny to the sites.If we type the...
0
by: r035198x | last post by:
Inheritance We have already covered one important concept of object-oriented programming, namely encapsulation, in the previous article. These articles are not articles on object oriented...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.