Ready to get started?

Learn more about the CData JDBC Driver for USPS or download a free trial:

Download Now

Publish Reports with USPS Data in Crystal Reports

Use the Report Wizard to design a report based on up-to-date USPS data.

Crystal Reports has many options for offloading data processing to remote data; this enables real-time reporting. With the support for JDBC in Crystal Reports, the CData JDBC Driver for USPS brings this capability to Crystal Reports. This article shows how to create a report on USPS data that refreshes when you run the report.

Deploy the JDBC Driver

Install the CData JDBC Driver for USPS by including the driver JAR in the Crystal Reports classpath: Add the full file path, including the .jar, to the paths in the ClassPath element, under the DataDriverCommonElement.

The CRConfig.xml is usually located at C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java — the path might be slightly different based on your installation. The driver JAR is located in the lib subfolder of the installation directory.

After you have added the JAR to the ClassPath, restart Crystal Reports.

Connect to USPS Data

After deploying the JDBC Driver for USPS, you can then use the Report Wizard to add USPS data to a new report.

  1. Click File -> New -> Standard Report.
  2. Expand the JDBC node under Create New Connection and double-click Make a New Connection.
  3. In the wizard, enter the JDBC connection URL:

    jdbc:usps:PostageProvider=ENDICIA; RequestId=12345; Password='abcdefghijklmnopqr'; AccountNumber='12A3B4C'

    To authenticate with USPS, set the following connection properties.

    • PostageProvider: The postage provider to use to process requests. Available options are ENDICIA and STAMPS. If unspecified, this property will default to ENDICIA.
    • UseSandbox: This controls whether live or test requests are sent to the production or sandbox servers. If set to true, the Password, AccountNumber, and StampsUserId properties are ignored.
    • StampsUserId: This value is used for logging into authentication to the Stamps servers. This value is not applicable for Endicia and is optional if UseSandbox is true.
    • Password: This value is used for logging into Endicia and Stamps servers. If the postage provider is Endicia, this will be the pass phrase associated with your postage account. It is optional if UseSandbox is true.
    • AccountNumber: The shipper's account number. It is optional if UseSandbox is true.
    • PrintLabelLocation: This property is required to use the GenerateLabels or GenerateReturnLabels stored procedures. This should be set to the folder location where generated labels should be stored.

    The Cache Database

    Many of the useful task available from USPS require a lot of data. To ensure this data is easy to input and recall later, utilize a cache database to make requests. Set the cache connection properties in order to use the cache:

    • CacheLocation: The path to the cache location, for which a connection will be configured with the default cache provider. For example, C:\users\username\documents\uspscache

    As an alternative to CacheLocation, set the combination of CacheConnection and CacheProvider to configure a cache connection using a provider separate from the default.

    Built-in Connection String Designer

    For assistance in constructing the JDBC URL, use the connection string designer built into the USPS JDBC Driver. Either double-click the JAR file or execute the jar file from the command-line.

    java -jar cdata.jdbc.usps.jar

    Fill in the connection properties and copy the connection string to the clipboard.

    When you configure the JDBC URL, you may also want to set the Max Rows connection property. This will limit the number of rows returned, which is especially helpful for improving performance when designing reports and visualizations.

  4. Set the driver class name:

    cdata.jdbc.usps.USPSDriver
  5. Select the tables and fields needed in the report. This example uses the FirstName and Phone columns from the Senders table.

You can then configure grouping, sorting, and summaries. For example, this article groups on FirstName and summarizes on Phone. See the following section to use the aggregate and summary to create a chart.

Create a Chart

After selecting a column to group by, the Standard Report Creation Wizard presents the option to create a chart. Follow the steps below to create a chart that aggregates the values in the FirstName column.

  1. In the Standard Report Creation Wizard, select the Bar Chart option and select the column you grouped by, FirstName in this example, in the On Change Of menu.
  2. In the Show Summary menu, select the summary you created.
  3. Select filters and a template, as needed, to finish the wizard.

Preview the finished report to view the chart, populated with your data. If you want to filter out null values, use a SelectionFormula.

Working with Remote Data

To ensure that you see updates to volatile data, click File and clear the "Save Data with Report" option. As you interact with the report, for example, drilling down to hidden details, Crystal Reports executes SQL queries to retrieve the data needed to display the report. To reload data you have already retrieved, refresh or rerun the report.

You can offload processing onto the driver by hiding details elements and enabling server-side grouping. To do this, you will need to have selected a column to group on in the report creation wizard.

  1. Click File -> Report Options and select the Perform Grouping On Server option.
  2. Click Report -> Section Expert and select the Details section of your report. Select the Hide (Drill-Down OK) option.

When you preview your report with the hidden details, Crystal Reports executes a GROUP BY query. When you double-click a column in the chart to drill down to details, Crystal Reports executes a SELECT WHERE query that decreases load times by retrieving only the data needed, instead of the entire table.