The stored procedure builder and related tools were rebuilt in V82 to
use the Java JCC driver instead of the old JDBC. Due to some
limitations of JCC, DB2 had to implement some cataloged versions of the
SQLJ-schema functions (install_jar, replace_jar) that took BLOB objects
as parameters instead of filenames. Here's a sample java program that
uses them - very basic, it just demonstrates their use:
import java.sql.*;
import java.lang.*;
import java.io.*;
//argv[0] -- database connection string (JCC format)
//argv[1] -- username
//argv[2] -- password
//argv[3] -- first JAR file
//argv[4] -- second JAR file
public class testinstjar
{
public static void main(String[] argv) throws Exception
{
Class.forName(" com.ibm.db2.jcc .DB2Driver").ne wInstance();
Connection conn = DriverManager.g etConnection(ar gv[0], argv[1],
argv[2]);
CallableStateme nt stmt = conn.prepareCal l("CALL
SQLJ.DB2_INSTAL L_JAR(?, ?)");
FileInputStream jarFile = new FileInputStream (argv[3]);
stmt.setBinaryS tream(1, jarFile, jarFile.availab le());
stmt.setString( 2, "MYJARID");
stmt.execute();
System.out.prin tln("Installjar complete");
stmt.close();
stmt = conn.prepareCal l("CALL SQLJ.DB2_REPLAC E_JAR(?, ?)");
jarFile = new FileInputStream (argv[4]);
stmt.setBinaryS tream(1, jarFile, jarFile.availab le());
stmt.setString( 2, "MYJARID");
stmt.execute();
System.out.prin tln("replacejar complete");
stmt.close();
stmt = conn.prepareCal l("CALL SQLJ.REMOVE_JAR (?)");
stmt.setString( 1, "MYJARID");
stmt.execute();
System.out.prin tln("removejar complete");
stmt.close();
conn.close();
}
}
NOTE: at this time, these functions are not documented for a reason --
they are ONLY intended for use with the stored procedure builder.
However, they function exactly like the normal SQLJ-schema functions
that have filenames for parameters, except that instead of filenames, a
BLOB representing the file is given instead.
In this case, although I'm not sure why, it looks like the procedure
builder is passing the engine some bad data (in the form of a
non-existent file) and that's resulting in a funny error.
A -444 usually means that a library (or function on that library) could
not be found, but I don't think that's the case here. I would check the
engine's <install>\bin\r outine (<install> is typically c:\sqllib)
directory and ensure that a file called db2jarsp.dll is present
(assuming your server is on a Windows machine).
However, as you say, the file that is being installed simply does not
exist on your client. That would lead me to think that the problem is
starting on the procedure builder, which then calls the
SQLJ.DB2_REFRES H_JAR() procedure to update the JAR file with some bad
data, which somehow results in the rather unusual -444 error you are seeing.
It might be worthwhile to contact IBM DB2 support about this. It may be
nice for them if you could run the test JAVA program above just to
ensure that the DB2_REFRESH_JAR (and install and remove procedures) are
actually working in normal conditions on your system. Any simple JAR
files will do - so long as they are actual JAR files containing java
classes.
hubert_s wrote:
I have DB2 8.1 FP7, when I try to build a Java stored procedure it fails
during a call to DB2_REPLACE_JAR . Even the build folder "bld10965539707 03"
is not there - it has a different name,
regards,
Hubert
DB2ADMIN.PROCED URE2 - Build started.
DROP SPECIFIC PROCEDURE DB2ADMIN.SQL030 805133228210
DB2ADMIN.PROCED URE2 - Drop stored procedure completed.
C:\PROGRA~1\IBM \SQLLIB\java\jd k\bin\javac -classpath
".;C:\PROGRA~1\ IBM\SQLLIB\java \db2java.zip;C: \PROGRA~1\IBM\S QLLIB\java\runt ime.zip;C:\PROG RA~1\IBM\SQLLIB \java\sqlj.zip" ;"c:\jt400.j ar"
procedure22.jav a
DB2ADMIN.PROCED URE2 - Javac completed.
C:\PROGRA~1\IBM \SQLLIB\java\jd k\bin\jar cf SQL307050132170 30.jar
procedure22.cla ss
DB2ADMIN.PROCED URE2 - Jar file created.
Call SQLJ.DB2_REPLAC E_JAR (<<C:\Document s and
Settings\db2adm in\Application
Data\IBM\DB2\DC \Projects\bld10 96553970703\SQL 30705013217030. jar>>,
'DB2ADMIN.SQL30 705013217030')
[IBM][CLI Driver][DB2/NT] SQL0444N Routine "SQLJ.DB2_REPLA CE_JAR"
(specific name "") is implemented with code in library or path "",
function "" which cannot be accessed. Reason code: "". SQLSTATE=42724
DB2ADMIN.PROCED URE2 - Build failed.
DB2ADMIN.PROCED URE2 - Roll back completed successfully.