To log onto a report database

One of the most basic ways you can programmatically interact with a report's data source is to logon to a report database. The ReportClientDocument object model allows you to submit the required logon credentials for any databases that a report connects to instead of forcing the user to do so when they attempt to view the report. The logon and logonEx methods will apply the logon credentials to all connections in the report, without forcing you to to individually set each table's connection.
Use these methods when you only want to change the logon credentials or database location, and not the type of data source or additional connection properties.
  1. Retrieve the DatabaseController object.
    DatabaseController databaseController = rcd.getDatabaseController();
  2. Call the logonEx method of the database controller to apply the logon credentials for the report database.

    Note: If the database server and name do not need changed, use thelogon method and pass in only the user name and password.
    String server = "<hostname>:<port>";
    String database = "databasename"
    String username = "yourUserName";
    String password = "yourPassword";
    databaseController.logonEx(server, database, username, password);
Example: 
The following code sets the logon credentials for all connections in a report.
void logonDatabase(ReportClientDocument rcd) throws ReportSDKException
{
    String server = "<hostname>:<port>";
    String database = "databasename"
    String username = "yourUserName";
    String password = "yourPassword";
    DatabaseController databaseController = rcd.getDatabaseController();
    databaseController.logonEx(server, database, username, password);
}
This list includes the classes used by the sample code:
  • com.crystaldecisions.sdk.occa.report.application.DatabaseController
  • com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
  • com.crystaldecisions.sdk.occa.report.lib.ReportSDKException