How to preserve state between calls to java UDRs
Posted in 2003
I'm trying to write a stored procedure in Java (UDR as it is called
in Informix) and execute it from an ODBC or a JDBC client.
First, I don't know any better discussion group to ask my question
than here. Can anybody tell me where I can find more about combining
Java and Informix on the server? Is this technology alive at all?
Do I have to bite into the Enterprise Java Beans to be able to
execute a dozen or so of stored procedures in Java?
Actually I have two questions, but the answer to one of them may
at the same time be the answer to the other.
1. How to preserve state between two calls from the same session
into the same class?
2. Why does it take so long to call a simple function, written in Java?
I wrote a simple Java function with two parameters, that makes a
simple SELECT on a database table and returns a value found there. I
did all that is needed to put the function in a jar, install the
jar on my server and make my function known with CREATE FUNCTION...
Now, if I call this function from dbaccess with EXECUTE FUNCTION I
wait about five seconds to see the result. If I call it immediately
afterwards, I get the result immediately, but when I call it the third
time, immediately or not, I wait again about five seconds. The same is
true if I make all these calls between BEGIN WORK and COMMIT WORK.
The same happens when I run the simple example JDBC that the server
installation leaves in directory $INFORMIXDIR/extend/krakatoa/examples.
I also try to preserve some values between two calls by putting the
objects with setUDRState into the UDREnv the way I found in
J/Foundation Developer's Guide, but I don't find them there on the
following call. I activated maximal tracing in .jvprops and see from the
trace that for every call of the Java function the JVP in the server
creates a new thread. I'd suppose there should be only one
thread for everything that is happening in one session. However
thread creating should also not take more than a fraction of a second,
let alone about 5 seconds.
In my installation I'm running Informix Dynamic Server 9.40 server
with J/Foundation option, JDK1.3.1_05 from Sun, Microsoft Windows
2000, all of this on Pentium 1800 MHZ with 400MB RAM.
I'm running applications with ordinary SPL stored procedures without
problems, so the installation should be sound, more or less.
Maks Romih.