Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Workroute and DB2
magikandrea
I'm trying to access a DB2 database from a delay node in a workflow.
To connect to the database I use the following JAVA code:
System.out.println("******* METODO GETTIPOAPPL ********");
String set = "";
ResultSet rs = null;
Vector lines = new Vector();
String q = "SELECT PLTI_TIPO, PLTI_DESCR FROM GRAPLTIPO0S";
try {
System.out.println("******* Class For Name ********");
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
System.out.println("******* Connection ********");
conn = DriverManager.getConnection("jdbc:db2:CAR_DB2M", "MFSDTS1", "STDS1");
System.out.println("******* Connection OK ********");
pst = conn.prepareStatement(q);
System.out.println("******* Statement OK ********");
rs = pst.executeQuery();
if(rs!=null){
System.out.println("******* Query OK ********");
while(rs.next()){
String line = rs.getString("PLTI_TIPO")+"-"+rs.getString("PLTI_DESCR");
lines.addElement(line);
}
}
for(int m=0;m<lines.size();m++){
set += (String)lines.elementAt(m)+"|";
}
set = set.substring(0,set.lastIndexOf("|"));
}catch(Exception e){
System.out.println("*********** "+e.getMessage()+" *********************");;
e.printStackTrace();
}
The code stops running after the "Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");" instruction. All the output is written into the imworkflow.0.stdout.log log file.
The problem is that into this log file I can see the error "WorkRoute could not evaluate the script. (java.lang.UnsatisfiedLinkError: SQLAllocEnv)" and I can't understand what it means.
As you can see I catch the exception and try to write it into the log file, but nothing is written.
Can anybody help me with this issue?
Thank you very much.
Find more posts tagged with
Comments
Migrateduser
Are you trying to execute the Java directly from the delay node, as a prologue or epilogue? WorkRoute MP scripting is basically Javascript plus a handful of addtional commands to, for example, get/set a user-defined attribute value (UDA). I think the approved solution for something like this would be to call out from the delay node to your Java code. This is example code we used to execute a command-line via Java code (since Javascript won't let you run a command line for security reasons).
var commandLine = "CMD /C echo foo > C:\\foo.txt";
var out = java.lang.System.out;
var helper = new Packages.com.imanage.cms.t2.workflow.engine.javascripthelper.others.ExecuteCommandHelper();
var processId = getProcessId();
var result = helper.execute(processId, commandLine);
out.println("result = " + result);
Kurt
Nicholas
What error you are getting in your Java Console?
well, in WOM, process templates can perform automatic actions with embedded JavaScript, JavaScript could be used to setup the call to Java via LiveConnect. You need to write the javascript to call Java class and then helper java class.
Only doExecute method throws WorkflowException and if you want to catch any other exception, you must catch them within subclass.
Thanks Nicholas
Migrateduser
>> The problem is that into this log file I can see the error "WorkRoute could not evaluate the script.
>> (java.lang.UnsatisfiedLinkError: SQLAllocEnv)" and I can't understand what it means.
This error comes when the java is not able to find the native libraries (part of JNI). Please check if you have properly copied the DB2 driver files (dll/so).
-bijoy
magikandrea
Hello, I solved my problem by using a new driver for DB2.
It seemed that I was using a wrong driver (old version).
Andrea