db2存储过程调用java_DB2 使用java存储过程,如何使存储过程中使用Axis

DB2 使用java存储过程,class要用Axis调用接口可以吗?,我将要用的jar(activation.jar、ant-1.8.2.jar、axis.jar、commons-discovery-0.2.jar、commons-logging-1.1.3.jar、jaxrpc.jar、log4j-1.2.15.jar、mail-1.4.jar、wsdl4j-1.6.3.jar)都打包到一个jar中,在调用时还是有错误

Java 程序:

import java.io.FileWriter;

import java.io.IOException;

import java.net.URL;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.PreparedStatement;

import java.sql.SQLException;

import javax.xml.namespace.QName;

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encoding.XMLType;

import org.apache.axis.message.MessageElement;

import org.apache.axis.message.SOAPHeaderElement;

public class DB2Java {

public static String writeLog(String name){

//appendMethodLog("C://work//log.txt",name);

String hh="";

try{

testSender("",name);

}catch(Exception e){

hh= e.getMessage();

appendMethodLog("C://work//log.txt",hh);

}

return name;

}

public static void appendMethodLog(String fileName, String content){

try {

FileWriter writer = new FileWriter(fileName, true);

writer.write(content);

writer.close();

} catch (IOException e) {

e.printStackTrace();

}

}

// 关键接口数据已经删掉了

public static String testSender(String receivers, String msgSmsContent)throws Exception{

System.out.println("testSender");

String rtnXml = "";

String url = "";

Service service = new Service();

Call call;

call = (Call) service.createCall();

call.setTargetEndpointAddress(new URL(url));

call.removeAllParameters();

call.setOperationName();

call.addParameter("fromSystem", XMLType.XSD_STRING,

javax.xml.rpc.ParameterMode.IN);

call.addParameter("msgType", XMLType.XSD_STRING,

javax.xml.rpc.ParameterMode.IN);

call.addParameter("sendToId", XMLType.XSD_STRING,

javax.xml.rpc.ParameterMode.IN);

call.addParameter("sendAtTime", XMLType.XSD_STRING,

javax.xml.rpc.ParameterMode.IN);

call.setReturnType(XMLType.SOAP_STRING);

String fromSystem = "";

String msgType = "";

String sendToId = receivers;

String sendAtTime = "";

rtnXml = (String) call.invoke(new Object[] { fromSystem, msgType,

sendToId, sendAtTime });

System.out.println("OK");

return rtnXml;

}

}

DB2注册:

CALL sqlj.replace_jar( 'file:///D:/Program Files (x86)/IBM/SQLLIB/FUNCTION/DB2Java.jar', 'DB2Java' )

call sqlj.refresh_classes

创建方法:

create Function writeLog(name varchar(30))

returns varchar(70)

fenced

variant

no sql

external action

language java

parameter style java

external name 'DB2Java.writeLog'

db2diag.log错误:

java.lang.ExceptionInInitializerError

at java.lang.J9VMInternals.initialize(J9VMInternals.java:255)

at org.apache.axis.handlers.BasicHandler.(BasicHandler.java:43)

at java.lang.J9VMInternals.initializeImpl(Native Method)

at java.lang.J9VMInternals.initialize(J9VMInternals.java:233)

at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)

at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)

at org.apache.axis.client.Service.getAxisClient(Service.java:104)

at org.apache.axis.client.Service.(Service.java:113)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值