If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > sqlj & updatejarinfo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-04, 17:25
db2me db2me is offline
Registered User
 
Join Date: Oct 2003
Location: Chicago
Posts: 5
sqlj & updatejarinfo

Ever tried scripting the creation of java stored procs on db2 and been successful at all but getting the class source to be updated in sysibm.sysjarcontents?

I succeeded in inserting the class source (from the original .java file) into
sysibm.sysjarcontents.class_source just today. I actually called
sqlj.updatejarinfo via OLEDB using a short VB sub:

Sub ProcUpdateJar(jarid, classid, jarurl)
Dim cxn, prc, pjarid, pclassid, pjarurl

Set cxn = CreateObject("ADODB.Connection")
cxn.Open "Provider=IBMDADB2;Data Source=SDPROD1;"

Set prc = CreateObject("ADODB.Command")
prc.CommandTimeout = 300
prc.ActiveConnection = cxn
prc.CommandType = adCmdStoredProc
prc.CommandText = "sqlj.updatejarinfo"
Set pjarid = prc.CreateParameter("jar-id", adVarChar, adParamInput, 128,
jarid) 'required
Set pclassid = prc.CreateParameter("class-id", adVarChar, adParamInput,
128, classid) 'required
Set pjarurl = prc.CreateParameter("jar-url", adVarChar, adParamInput,
128, jarurl) 'required
prc.Parameters.Append pjarid
prc.Parameters.Append pclassid
prc.Parameters.Append pjarurl
prc.Execute

Set pjarid = Nothing
Set pclassid = Nothing
Set pjarurl = Nothing

Set prc = Nothing
End Sub

This worked for me executed from a VBA module in MS Access on a Win2k machine.

The DB2 instance version is DB2/6000 8.1.5.

The jarid was
SDT001.PROCTEST

The classid was
PROCTEST

The source PROCTEST.java file was located on the db2 host filesystem at
/db2inst/ts/work/PROCTEST.java

The sub was executed from the client system with
ProcUpdateJar "SDT001.PROCTEST","PROCTEST","file:/db2inst/ts/work/PROCTEST.java"

Though as yet untested, I assume this would work just as well similarly called from C/C++, java, etc. Pure speculation is there is an imcompatibility somewhere in the CLP interface that is bypassed when sqlj.updatejarinfo is called via the OLE/DB interface instead.

Let me know if you adapt it to java or something else I might be able to
execute from command-line - I'll probably try java next myself, otherwise
compile a quick .exe from the VB.

Hope this helps.

Tim Erickson
http://www.in2words.org
Reply With Quote
  #2 (permalink)  
Old 08-13-04, 17:55
db2me db2me is offline
Registered User
 
Join Date: Oct 2003
Location: Chicago
Posts: 5
java class to updatejarinfo

import java.lang.*;
import java.sql.*;

class clUpdateJarInfo {
public static void main (String[] args) throws SQLException, ClassNotFoundException {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
Connection cxn = DriverManager.getConnection("jdbc:db2DPROD1");
CallableStatement cs;

//thanks to
//http://javaalmanac.com/egs/java.sql/CallProcedure.html
//for the jumpstart on this code

cs = cxn.prepareCall("{call sqlj.updatejarinfo(?, ?, ?)}");
cs.setString(1, args[0]);
cs.setString(2, args[1]);
cs.setString(3, args[2]);
cs.execute();
}
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On