Testing Java applications that use JDBC

To enable the JDBC proxy to capture SQL being used by an application and to test Java application that use JDBC, you must load the driver into the application JVM.

About this task

Note: Currently, JDBC 4, Java 1.6 or later is supported for the JDBC proxy and its supporting libraries. You must add the three JAR files com.ibm.rational.rit.jdbcdriver4.jar, jsqlparser15.jar and antlr-3.4.jar to each application server directory that contains JDBC drivers.

To load the driver into the application's JVM, modify the startup parameters of the Java application as follows:

Procedure

  1. The JDBC proxy requires a number of supporting files to run. Download and extract the JDBC driver package that is provided with Rational® Test Control Panel. For more information, see Rational Integration Tester tool packages.
  2. Copy the files that are listed in the following table from the downloaded JDBCIntercept.zip package to the Java applications CLASSPATH.

    Alternatively, modify the applications CLASSPATH to point to the files.

    JDBC / Java version File name Description
    JDBC 4, Java 1.6 or later

    com.ibm.rational.rit.jdbcdriver4.jar

    jsqlparser15.jar and antlr-3.4.jar

    The JDBC proxy.

    Supporting libraries.

    Notes:
    • Currently, JDBC 4, Java 1.6 or later is supported for the JDBC proxy and its supporting libraries. You must add the three JAR files com.ibm.rational.rit.jdbcdriver4.jar, jsqlparser15.jar and antlr-3.4.jar to each application server directory that contains JDBC drivers.
    • The following items are not supported for vendor-specific Oracle SQLs:
      • Oracle-specific DDL statements
      • Custom functions
      • Subqueries
      • PIVOT and UNPIVOT statements
      • Nested tables containing multiple columns or single column of user-defined-types
      • Stubs with nested tables
    When the application class path loads the driver, the registration.xml file is searched for in the same directory as the location of the driver. Some applications do not allow registration.xml to be placed along with the JAR files, which might cause startup errors, or they cannot access the file in this location. In such cases, copy registration.xml into a different folder and add the following line to the Java application invocation command line or system properties: -Dcom.greenhat.registration=C:\myWebServer\config\registration.xml.
    Note: If the container is IBM® WebSphere® Application Server, installation of the driver is performed by means of a set of scripts provided in the downloaded JDBCIntercept packages.
  3. Edit the invocation command line or the system properties within the Java application to modify the jdbc.drivers property as follows:
    -Djdbc.drivers=com.greenhat.jdbc.Driver
    Note: If there is already a -D entry that is specifying drivers, ensure that com.greenhat.jdbc.Driver is listed first and that the other entries appended after are in a colon-separated list.
  4. Edit the server tag in the registration.xml file to the URL of the IBM® Rational® Test Control Panel installation that is being used.

    For information about modifying this file, refer to Modifying the configuration settings of the JDBC proxy.

  5. Optional: Edit the domain and environment tags in the registration.xml file.

    If these tags are modified, the JDBC Proxy is used only when recording/stubbing within the specified domain and environment.

  6. Run the Java application.
  7. Use Rational® Integration Tester and Rational® Test Control Panel to control JDBC recording and stubbing. For more information, see Rational Integration Tester reference and Rational Test Virtualization Server overview.