To use LOAD from a SP, you would have to write the SP in a language like C++. To do it from Java, it would look like this:
// This is code to connect to DB, then a loop to do successive loads, then disconnect
// do import work
System.out.println("Connect");
runTime = Runtime.getRuntime();
db2Command = new StringBuffer("DB2 CONNECT TO ");
db2Command.append(getDbName());
db2Command.append(" USER ");
db2Command.append(dbLogin.getLoggedInUsername());
db2Command.append(" USING ");
db2Command.append(dbLogin.getLoggedInPassword());
child = runTime.exec(db2Command.toString());
inStream = new java.io.InputStreamReader(child.getInputStream());
buffReader = new java.io.BufferedReader(inStream);
inLine = null;
while ((inLine = buffReader.readLine()) != null) {
System.out.println(inLine);
}
exitVal = child.waitFor();
// import data
tigerPath = new File(dataDirectory);
for (i=0; i< rts.length; ++i)
{
importRT(tigerPath,rts[i],cl[i],nl[i],col[i]);
}
System.out.println("Disconnect");
runTime = Runtime.getRuntime();
child = runTime.exec("DB2 DISCONNECT ALL");
inStream = new java.io.InputStreamReader(child.getInputStream());
buffReader = new java.io.BufferedReader(inStream);
inLine = null;
while ((inLine = buffReader.readLine()) != null) {
System.out.println(inLine);
}
exitVal = child.waitFor();
// this is the function to load
public static void importRT(File dir, String recordType, String columnLocations, String nullIndicators, String columns){
int i;
StringBuffer importCommand;
java.io.InputStreamReader inStream;
java.io.BufferedReader buffReader;
String inLine;
int exitVal;
String retString;
try {
final String fileType = new String("." + recordType);
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toUpperCase().endsWith(fileType);
}
};
plString = new String(recordType);
String files[] = dir.list(filter);
progMax = files.length;
progCurrent = 0;
display.asyncExec(importTiger);
for (i=0; i< files.length; ++i)
{
importCommand = new StringBuffer("DB2 LOAD CLIENT FROM ");
importCommand.append(dir.getPath());
importCommand.append("\\");
importCommand.append(files[i]);
importCommand.append(" OF ASC METHOD L ");
importCommand.append(columnLocations);
importCommand.append(" NULL INDICATORS ");
importCommand.append(nullIndicators);
importCommand.append(" MESSAGES ");
importCommand.append(dir.getPath());
importCommand.append("\\");
importCommand.append(files[i]);
importCommand.append(".ldm INSERT INTO ANDY.TIGER_");
importCommand.append(recordType);
importCommand.append(" ");
importCommand.append(columns);
importCommand.append(" nonrecoverable without prompting ");
System.out.println(importCommand.toString());
//cStmt.setString(1,importCommand.toString());
//cStmt.execute();
//rs = cStmt.getResultSet();
// get node for database name
child = runTime.exec(importCommand.toString());
inStream = new java.io.InputStreamReader(child.getInputStream());
buffReader = new java.io.BufferedReader(inStream);
inLine = null;
while ((inLine = buffReader.readLine()) != null) {
System.out.print(inLine+"\n");
}
exitVal = child.waitFor();
progCurrent = i+1;
display.asyncExec(importTiger);
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
HTH
Andy