For the record, I tried the UDF (just using the "VALUES" SQL statement,
not inside the trigger) and it worked fine for me. Mind you, I'm using
a patched DB2 that has some known JAVA SP/UDF problems (APARs) fixed --
LI70535 (affecting FP6-FP8) in particular, which IBM should be releasing
as part of FP9 -- and on AIX, not Windows.
There are some problems with his code from the article though. For one,
you cannot print information using println() like he does. The FMP is a
daemon process; it has no STDOUT/STDERR, and hence those messages have
nowhere to appear. What I suspect is happening is you're getting an
exception, and the code is trying to handle it but the println is
causing problems -- try taking that out and seeing what happens. I'd
have code the UDF to simply let the exception happen, in which case the
trigger will received a -4302 SQLCODE and the message & call stack from
the exception (rather than just the message his design will return) will
be written to the db2diag.log. You'd need to change the design of the
trigger to handle the -4302 if you had more than one record to update,
but I think knowing the entire exception would be more useful than the
partial message is more useful.
Other than that... sqloJVMvfprintf() is a function registered with the
JVM when it is started up by DB2. It's intent is that if the JVM has a
message it itself needs to report (ie, not just something from
System.out) then it will be routed to the db2diag.log. However, I
cannot make heads or tails of the messages it printed out below.
I should point out though that JDK 1.4.1 is only supported on V82 (ie,
FP7) or higher. I don't know what level you're on, but this should be
addressed if you're pre-V82.
> I am trying to write a trigger/UDF combination that closely follows the
> example given in the following DeveloperWorks article:
[quoted text clipped - 64 lines]
> FUNCTION: DB2 UDB, oper system services, sqloJVMvfprintf, probe:20
> MESSAGE : 0x00af90b0
Rhino - 30 Mar 2005 21:28 GMT
> For the record, I tried the UDF (just using the "VALUES" SQL statement,
> not inside the trigger) and it worked fine for me. Mind you, I'm using
[quoted text clipped - 15 lines]
> but I think knowing the entire exception would be more useful than the
> partial message is more useful.
Actually, I don't have any println() statements in my code. I imitated the
article pretty closely but I knew that println() wouldn't work so I replaced
the println() statements with writes to a flat file. This functions as a
basic log file and I know that the code works because I've used it in many
other UDFs to debug the code. I also had some writes immediately after
entering the method to display the values on the input parameters and they
were written successfully. But the code never gets to the end of the method;
it dies sometime after printing the parameters but before the next write.
As far as error handling goes, all of the code is in a big try block that
catches Exception and simply throws a new SQLException displaying the method
name, the message from the Exception, and SQLstate "38600". If no Exception
is caught, the method ends with
return "An E-mail was sent to " + cardholderEmail
But I've never seen the UDF display either that line nor any exception: when
the UDF, which should finish in a second or two still hadn't come back after
20 minutes and I realized that db2diag.log was growing by leaps and bounds,
I just killed the processes so that I could try to debug the problem. Maybe
I should have just let it end on its own but after 20 minutes, it didn't
seem like it *was* going to end by itself.
> Other than that... sqloJVMvfprintf() is a function registered with the
> JVM when it is started up by DB2. It's intent is that if the JVM has a
> message it itself needs to report (ie, not just something from
> System.out) then it will be routed to the db2diag.log. However, I
> cannot make heads or tails of the messages it printed out below.
Yeah, I probably needed to put more of the db2diag.log in the note but it
literally goes on for millions of lines and I had no idea how much of the
log was needed to diagnose the problem. I manually edited db2diag.log
afterwards to remove all of those lines but I could run the UDF again to
recreate the error and then post more of the log if you think that would
help. How much of the log would be enough to help you make sense of it? 1000
lines?
> I should point out though that JDK 1.4.1 is only supported on V82 (ie,
> FP7) or higher. I don't know what level you're on, but this should be
> addressed if you're pre-V82.
I'm on V8.2 with FP8 installed so we shouldn't have an issue with code
levels.
Rhino