Using the workbench to run restricted sets of SQL statements dynamically

The workbench provides features for capturing SQL statements from applications that run against DB2®, Informix® Data Server, and Oracle data sources. You can use pureQuery to ensure that an application runs only the SQL statements that you captured.

Before you begin

Ensure that your system meets the hardware and software requirements. See System requirements for InfoSphere™ Optim™ pureQuery Runtime.

The application must be located in a Java project in the workbench.

About this task

To run only the SQL statements that are captured in a pureQueryXML file:

Procedure

  1. Enable pureQuery to capture the SQL statements that are in your application.
    • If your Java project does not yet support pureQuery, right-click your Java project and select Data Access Management and then click either Add Data Access Management Support or Add pureQuery Support. Follow the steps in the Add Data Access Management Support wizard. For information about the controls on the wizard, click Help in the lower-left corner of the wizard. If the help does not appear, select a control on the Add pureQuery Support page and then click Help again.
    • If your Java project already supports pureQuery, follow these steps to ensure that you can capture SQL statements:
      1. Right-click your Java project and select Properties.
      2. In the Properties dialog, select the pureQuery page.
      3. Select the Enable SQL capturing for JDBC applications check box.
      4. In the Location for pdq.properties file field, browse to select the pdq.properties file in the project for your application. If you do not yet have such a file, the workbench creates one for you in the folder that it displays in the field.
  2. Optional: Create JUnit tests for your non-pureQuery API application that run all of the SQL statements that you want to capture. If you do not create unit tests, you must run the application so that it executes all of the SQL statements that you eventually want to run statically.

    For information about JUnits in the workbench, see Writing and running JUnit tests.

  3. Capture SQL statements.
    When you are setting values for the relevant properties, ensure that the property pureQueryXml, outputPureQueryXml, or both are set to dataAccessFolder/file-name. If you do not set a value, the workbench uses dataAccessFolder/capture.pdqxml. For the workbench to recognize the pureQueryXML file, the file must be in the dtatAccessFolder folder in your Java project.

    After you set the values for the properties, run your application or your JUnit tests.

    After you are finished, the workbench creates in your Java project the pureQueryXML files that you specified. You can repeat this step if you did not capture all of the SQL statements in your application and want to capture the rest of them.

  4. Optional: Edit or merge the pureQueryXML files that you created.
  5. Run your application with the pureQueryXML files that contain the SQL statements that you have approved.

Feedback