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").newInst ance();
Connection conn = DriverManager.getConnection(argv[0], argv[1],
argv[2]);
CallableStatement stmt = conn.prepareCall("CALL
SQLJ.DB2_INSTALL_JAR(?, ?)");
FileInputStream jarFile = new FileInputStream(argv[3]);
stmt.setBinaryStream(1, jarFile, jarFile.available());
stmt.setString(2, "MYJARID");
stmt.execute();
System.out.println("Installjar complete");
stmt.close();
stmt = conn.prepareCall("CALL SQLJ.DB2_REPLACE_JAR(?, ?)");
jarFile = new FileInputStream(argv[4]);
stmt.setBinaryStream(1, jarFile, jarFile.available());
stmt.setString(2, "MYJARID");
stmt.execute();
System.out.println("replacejar complete");
stmt.close();
stmt = conn.prepareCall("CALL SQLJ.REMOVE_JAR(?)");
stmt.setString(1, "MYJARID");
stmt.execute();
System.out.println("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\routine (<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_REFRESH_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 "bld1096553970703"
is not there - it has a different name,
regards,
Hubert
DB2ADMIN.PROCEDURE2 - Build started.
DROP SPECIFIC PROCEDURE DB2ADMIN.SQL030805133228210
DB2ADMIN.PROCEDURE2 - Drop stored procedure completed.
C:\PROGRA~1\IBM\SQLLIB\java\jdk\bin\javac -classpath
".;C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;C:\PROG RA~1\IBM\SQLLIB\java\runtime.zip;C:\PROGRA~1\IBM\S QLLIB\java\sqlj.zip";"c:\jt400.jar"
procedure22.java
DB2ADMIN.PROCEDURE2 - Javac completed.
C:\PROGRA~1\IBM\SQLLIB\java\jdk\bin\jar cf SQL30705013217030.jar
procedure22.class
DB2ADMIN.PROCEDURE2 - Jar file created.
Call SQLJ.DB2_REPLACE_JAR (<<C:\Documents and
Settings\db2admin\Application
Data\IBM\DB2\DC\Projects\bld1096553970703\SQL30705 013217030.jar>>,
'DB2ADMIN.SQL30705013217030')
[IBM][CLI Driver][DB2/NT] SQL0444N Routine "SQLJ.DB2_REPLACE_JAR"
(specific name "") is implemented with code in library or path "",
function "" which cannot be accessed. Reason code: "". SQLSTATE=42724
DB2ADMIN.PROCEDURE2 - Build failed.
DB2ADMIN.PROCEDURE2 - Roll back completed successfully.