【BO-SDK】-(RAS) DB_Connection Changing _@Z01
时间:2010-09-24 来源:xiangjinling
....
IInfoObjects oInfoObjects=null;
IInfoObject oInfoObject=null;
IEnterpriseSession boEnterpriseSession;
ReportClientDocument myClientDocument=null;
try {
boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( username, password, cmsName, authType);
IInfoStore boInfoStore = (IInfoStore) boEnterpriseSession.getService("", "InfoStore");
oInfoObjects = (IInfoObjects) boInfoStore.query("Select * from CI_INFOOBJECTS Where SI_INSTANCE=0 And SI_ID='16578'");
oInfoObject = (IInfoObject) oInfoObjects.get(0);
IReportAppFactory myReportfactory=(IReportAppFactory)boEnterpriseSession.getService("RASReportFactory");
myClientDocument=myReportfactory.openDocument(oInfoObject, 0, Locale.getDefault()) ;
DatabaseController dbController=myClientDocument.getDatabaseController();
PropertyBag promptProperties = new PropertyBag();
promptProperties.putBooleanValue( PropertyBagHelper.PROMPTPROPERTY_ALL, true );
promptProperties.putBooleanValue( PropertyBagHelper.PROMPTPROPERTY_INCLUDEONDEMANDSUBREPORT, true );
promptProperties.putBooleanValue( PropertyBagHelper.PROMPTPROPERTY_INCLUDEMETADATASUBCONNECTIONS, true );
promptProperties.putBooleanValue( PropertyBagHelper.PROMPTPROPERTY_INCLUDEOLAPCONNECTIONS, true );
ConnectionInfos connectionInfos=dbController.getConnectionInfos(promptProperties);
IConnectionInfo oldConnection_=connectionInfos.getConnectionInfo(0);
//ConnectionInfos oConnectionInfos = new ConnectionInfos();
IConnectionInfo newIConnectionInfo = new ConnectionInfo();
newIConnectionInfo.setKind( ConnectionInfoKind.CRQE );
newIConnectionInfo.setUserName("user777");
newIConnectionInfo.setPassword("777");
PropertyBag attributes=newIConnectionInfo.getAttributes();
attributes.put( PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_opensql");
PropertyBag logonPb = new PropertyBag();
logonPb.put("PreQEServerName", "myserver7.sap.corp");
logonPb.put("PreQEDatabaseName", "CLIENT=102 LANG=EN ASHOST="myserver7.sap.corp" SYSNR=04 R3NAME=EH4");
attributes.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, logonPb);
//attributes.put("QE_LogonProperties", logonPb);
//oConnectionInfos.add(oIConnectionInfo);
dbController.replaceConnection(oldConnection_, newIConnectionInfo, null, DBOptions._doNotVerifyDB);
//myClientDocument.verifyDatabase();
myClientDocument.save();
} catch (SDKException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReportSDKException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-----------------------------------------
IConnectionInfo oldConnection=connectionInfos.getConnectionInfo(0);
PropertyBag attrius=oldConnection.getAttributes();
attrius.get("QE_ServerDescription")...
QE_ServerDescription
QE_SQLDB
QE_DatabaseType
QE_DatabaseName
QE_LogonProperties
SSO Enabled
Database DLL
-------------------
PropertyBag logpb=(PropertyBag)attrius.get("QE_LogonProperties");
logpb.get("sap_selected_system")....
sap_selected_system
CODEPAGE
CLIENT
Database
LANG
SSOKEY
Server
SYSNR
ASHOST
------------------------------------------