Domino通过SAPJCO.jar连接SAP的问题.
//当运行到JCO.createClient时,产生如下错误. 请高手指点.
01/20/2008 07:17:02 PM AMgr: Agent ('(Java XXX SAP) | jagCreateSO' in 'Develop\XXXProject\xxxapp.nsf') error message: java.lang.ExceptionInInitializerError: JCO.classInitialize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
D:\Lotus\Domino\jvm\lib\ext\x86\sapjcorfc.dll
import java.io.PrintWriter;
import lotus.domino.*;
import com.sap.mw.jco.*;
/**
* @author Thomas G. Schuessler, ARAsoft GmbH http://www.arasoft.de
*/
public class JC_SAP {
JCO.Client mConnection;
private String sReturnMsg = "";
JCO.Repository mRepository;
private Database dbCur = null;
private Document docSys = null;
private View vwSys = null;
private PrintWriter pw;
public JC_SAP(AgentContext agContext, PrintWriter pw) {
try {
dbCur = agContext.getCurrentDatabase();
this.pw = pw;
initialSAP("vAdminSysConfig");
} catch (NotesException e) {
this.setSReturnMsg(e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public JC_SAP(AgentContext agContext, PrintWriter pw,String sViewName) {
try {
dbCur = agContext.getCurrentDatabase();
this.pw = pw;
initialSAP(sViewName);
} catch (NotesException e) {
this.setSReturnMsg(e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void initialSAP(String sViewName) throws NotesException {
vwSys = dbCur.getView(sViewName);
docSys = vwSys.getFirstDocument();
try {
System.out.print(JCO.TYPE_FLOAT);
// Change the logon information to your own system/user
System.out.println(docSys.getItemValueString("SAPHostname"));
mConnection = JCO.createClient(docSys
.getItemValueString("SAPClient"), // SAP client
docSys.getItemValueString("SAPUser"), // userid
docSys.getItemValueString("SAPPassword"), // password
docSys.getItemValueString("SAPLanguage"), // language
docSys.getItemValueString("SAPHostname"), // server_host
docSys.getItemValueString("SAPSystem")); // system number
mConnection.connect();
mRepository = new JCO.Repository("ARAsoft", mConnection);
} catch (Exception e) {
System.out.print(e.getLocalizedMessage());
this
.setSReturnMsg("To connect SAP failed. please check connection string...");
e.printStackTrace();
// System.exit(1);
}
mConnection.disconnect();
}
public JCO.Function createFunction(String name) throws Exception {
try {
IFunctionTemplate ft = mRepository.getFunctionTemplate(name
.toUpperCase());
if (ft == null)
return null;
return ft.getFunction();
} catch (Exception e) {
this.setSReturnMsg("Problem retrieving JCO.Function object " + name
+ ".");
return null;
}
}
public void logoff() {
this.mConnection.disconnect();
}
public String getSReturnMsg() {
return sReturnMsg;
}
public void setSReturnMsg(String returnMsg) {
sReturnMsg = sReturnMsg + "<br>" + "<font>" + returnMsg + "</font>";
}
}