facebook

Setting Up a JDBC Data Source for Reporting

MyEclipse Reports is designed to share JDBC drivers configured for use with database tools. A special data source, the MyEclipse JDBC data source, allows the reporting tools access to these drivers. This tutorial shows you how to set up the MyEclipse JDBC data source. You will learn how to:

  • Create and edit a data source
  • Manually sync a data source
This feature is available in MyEclipse.


1. Creating a MyEclipse JDBC Data Source

  1. Open the Report Design perspective by selecting Windows>Open Perspective>MyEclipse Report Design.
  2. Launch the Report Designer by either creating a report or opening an existing report. 
  3. In the Data Explorer, right-click Data Sources, and select New Data Source.

    If this view is not visible, select Window>Show View>Other, expand MyEclipse Report Design, and select Data Explorer.

    Creating a new data source
  4. Select the MyEclipse JDBC Data Source, type MyEclipse Derby DS in Data Source Name field, and click Next.

    Selecting data source type
  5. Select MyEclipse Derby from the Driver drop-down, and click Finish.

    If you want to create a new MyEclipse JDBC driver, click the Create new driver link. You can also edit existing drivers using the Edit driver link. 

    Note:
    To provide seamless MyEclipse Reports integration, only drivers with saved passwords can be selected. To learn more about MyEclipse drivers, please see Connecting to a Database in MyEclipse.

    Selecting a driver
  6. Enter a descriptive name in the Data Source general properties.

    Naming the datasource

The new MyEclipse Derby DS data source appears in the Data Explorer view.

MyEclipse Derby DS data source

During the process of creating the new MyEclipse JDBC data source, the Database Explorer JDBC driver properties, namely, connection URL, driver class name, username and password, are copied into the report file. Additionally, the Database Explorer JDBC driver’s JAR files are copied into the folder, <projectName>/WebRoot/Web-INF/report-engine/platform/plugins/org.eclipse.birt.report.data.oda.jdbc_<version>/drivers. These JAR files are deployed along with your report’s web project.

 


2. Editing a MyEclipse JDBC Data Source

During the life-cycle of a MyEclipse JDBC data source, you might  need to rename the data source or change the associated MyEclipse JDBC driver bound to the data source.

2.1 Renaming a Data Source

To rename a data source, right-click the data source in the Data Explorer, and select Rename. The name you use must be unique to the current report.

2.2 Changing the Database Explorer JDBC Driver Bound to a Data Source

  1. In the Data Explorer, expand Data Sources, right-click the data source you want to modify, and select Edit.

    Editing a data source
  2. Select a new MyEclipse driver from the Driver drop-down, and click OK to commit these changes to your report.

    MyEclipse JDBC data source editor

If you change the associated MyEclipse driver, driver JAR(s) from the new driver are copied into your project.

Because the MyEclipse JDBC data source is coupled with a MyEclipse JDBC driver, the data source’s JDBC properties cannot be directly edited in the data source. To change these properties, you must edit them in the associated Database Explorer driver.

 

3. Manually Sync’ing the JDBC Data Source

A stale JDBC Data Source situation can persist after the automatic synchronization described in Reporting Tools in MyEclipse. There are several reasons this can happen. For example, the data source validator can not detect stale data sources in a project that is closed; therefore these resources are not available in the Synchronization window. In such cases, it is possible to manually synchronize the JDBC data source.

  1. In the Data Explorer, right-click the stale JDBC data source, and select Edit.

    Manual synchronization
  2. In the left column, select MyEclipse JDBC Data Source, and click Synchronize Driver.
    Since your report’s data source is connected to a MyEclipse JDBC driver, when you preview the results in the Report Designer Preview page, the JDBC properties from the associated Database Explorer JDBC driver are used to establish the database connection, irrespective of the JDBC properties that might be stored in your report file. At runtime, the JDBC properties in your report are used.
      If you provide custom data source property bindings, these bound properties take precedence over the Database Explorer JDBC driver properties even for the Preview operation. If incorrect property values are specified, an unsuccessful database connection might result.

      Editing property binding