Skip to Content
0
Former Member
Nov 24, 2008 at 09:48 AM

How to programmatically change database source ?

127 Views

Hi,

Crystal Reports 2008

BusinessObjects Enterprise 12.0

I want to change the database config properties of existing report file (rpt) in BO.( Just like the one in CMC : "Database configuration")

I have referred rassdk developer guide and write the sample below.

...
IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");		
// Open the report file for this sample.
clientDoc = reportAppFactory.openDocument(infoObject,OpenReportOptions._refreshRepositoryObjects, java.util.Locale.US);


DatabaseController databaseController = clientDoc.getDatabaseController();
ConnectionInfos connectInfos = (ConnectionInfos)databaseController.getConnectionInfos(null);

IConnectionInfo oldConnectionInfo = connectInfos.getConnectionInfo(0);
IConnectionInfo newConnectionInfo = new ConnectionInfo();

newConnectionInfo.setKind(ConnectionInfoKind.CRQE);

PropertyBag QELogonProperties = new PropertyBag();
QELogonProperties.put("DSN", "myDsn");
QELogonProperties.put("UseDSNProperties", true);

PropertyBag QEProperties = new PropertyBag();
QEProperties.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, QELogonProperties);
QEProperties.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_p2ssyb10.dll");
QEProperties.put(PropertyBagHelper.CONNINFO_CRQE_DATABASENAME, "myDb");
QEProperties.put(PropertyBagHelper.CONNINFO_CRQE_DATABASETYPE, "Sybase Server");
QEProperties.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, "Dev DB");
QEProperties.put(PropertyBagHelper.CONNINFO_CRQE_SQLDB, true);
QEProperties.put(PropertyBagHelper.CONNINFO_SSO_ENABLED, false);

newConnectionInfo.setAttributes(QEProperties);
newConnectionInfo.setUserName("UserName");
newConnectionInfo.setPassword("Password");

try {
		databaseController.replaceConnection(oldConnectionInfo, newConnectionInfo, null, DBOptions._useDefault);
}
		
catch (ReportSDKServerException error) {
		out.println(error.getServerError());
}
// Save the change                                                 
clientDoc.save();

I also tried another way below, but failed to save to rpt file in BO either.

..
clientDoc.getDatabaseController().logonEx("myServer","myDb","user","password);
clientDoc.save();

I have now found this topic:

https://www.sdn.sap.com/irj/scn/thread?messageID=6285331#6285331

Is it no way to change the data connection properties of report file in BO in Java SDK ?

Best regards and thanks

Forest