如题,环境:操作系统是server2012 R2 64位 jdk:1.7 64位 tomcat 8.5 64位 DI:9.0 64位
如下是连接的代码,在运行时报错,已检查过 连接信息没有问题,望解答。
public static void main(String[] args)
{
ICompany company;
int connectionResult = 0;
try
{
// initialise company instance
company = SBOCOMUtil.newCompany();
// set database server host
company.setServer("XXXXX");
// set company database
company.setCompanyDB("XXXXX");
// set SAP user
company.setUserName("manager");
// set SAP user password
company.setPassword("XXXX");
// set SQL server version
company.setDbServerType(SBOCOMConstants.BoDataServerTypes_dst_MSSQL2012);
// set whether to use trusted connection to SQL server
company.setUseTrusted(new Boolean(false));
// set SAP Business One language
company.setLanguage(SBOCOMConstants.BoSuppLangs_ln_English);
// set database user
company.setDbUserName("sa");
// set database user password
company.setDbPassword("XXXX");
// set license server and port
company.setLicenseServer("XXXX:30000");
// initialise connection
connectionResult = company.connect();
// if connection successful
if (connectionResult == 0)
{
System.out.println("Successfully connected to " + company.getCompanyName());
company.disconnect();
}
// if connection failed
else
{
// get error message fom SAP Business One Server
SBOErrorMessage errMsg = company.getLastError();
System.out.println(
"Cannot connect to server: "
+ errMsg.getErrorMessage()
+ " "
+ errMsg.getErrorCode()
);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
运行结果及报错内容
com.sap.smb.sbo.wrapper.com.ComFailException: Can't map name to dispid: Server
at com.sap.smb.sbo.wrapper.com.Dispatch.invokev(Native Method)
at com.sap.smb.sbo.wrapper.com.Dispatch.invokev(Unknown Source)
at com.sap.smb.sbo.wrapper.com.Dispatch.invoke(Unknown Source)
at com.sap.smb.sbo.wrapper.com.Dispatch.put(Unknown Source)
at com.sap.smb.sbo.api.Company.setServer(Unknown Source)
at BNDPS.modular.tosap.ConnectToServer.main(ConnectToServer.java:34)