Data source connection properties

When changing a data source connection, you must specify the connection properties in your IConnectionInfo object. Specify these properties in a com.crystaldecisions.sdk.occa.report.lib.PropertyBag object and set them using the com.crystaldecisions.sdk.occa.report.data.IConnectionInfo.setAttributes method. There are two distinct sets of properties to define values for:
  • Default connection properties
    Every general kind of data source (com.crystaldecisions.sdk.occa.report.data.ConnectionInfoKind) has a set of default properties that can be set. For example, you can set the following properties for all Crystal Report Query Engine (CRQE) connections:
    PropertyBag properties = new PropertyBag();
    properties.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_dbtype.dll");   
    properties.put(PropertyBagHelper.CONNINFO_SERVER_NAME, "DBName");
    properties.put(PropertyBagHelper.CONNINFO_SERVER_TYPE, "User friendly database type description");
    properties.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, "User friendly server description");
    properties.put(PropertyBagHelper.CONNINFO_CRQE_SQLDB, true);
    properties.put(PropertyBagHelper.CONNINFO_SSO_ENABLED, false);
  • Custom logon properties
    Each data source type has a different set of required logon properties. Store these properties in a second PropertyBag object and set them as the value of the PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES key for the main connection properties. Here is an example for connecting to a local XML data source:
    PropertyBag logonProperties = new PropertyBag();
    logonProperties.put("Local XML File", "C:\\customer.xml");
    logonProperties.put("Local Schema File", "C:\\customer.xsd");
    logonProperties.put("Convert Multivalue to Table", false); 
    
    properties.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, logonProperties);

Tip: To more easily identify the key-value pairs of connection properties you can change for your data source, iterate through the property bag of an existing connection in a report (created through the Crystal Reports Designer) using the IConnectionInfo.getAttributes method.
String displayConnectionProperties(IConnectionInfo connectionInfo) throws ReportSDKException
{
  PropertyBag properties = connectionInfo.getAttributes();

  ConnectionInfoKind connectionInfoKind = connectionInfo.getKind();
  String propertiesString = connectionInfoKind.toString() + "<p>";
  propertiesString +=  "<table><tr><td><strong>Key</strong></td><td><strong>Value</strong></td></tr>";

  IStrings ids = properties.getPropertyIDs();
  Iterator<String> it =  ids.iterator();


  while (it.hasNext())
  {
    String key = it.next();
    String value = properties.getStringValue(key);
    propertiesString += "<tr><td>" + key + "</td><td>" + value + "</td></tr><p>";       
  } 
  propertiesString += "</table>";
  return propertiesString;
}
This list includes the classes used by the sample code:
  • com.crystaldecisions.sdk.occa.report.data.IConnectionInfo
  • com.crystaldecisions.sdk.occa.report.lib.IStrings
  • com.crystaldecisions.sdk.occa.report.lib.PropertyBag
  • com.crystaldecisions.sdk.occa.report.lib.ReportSDKException
  • java.util.Iterator