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
- The JDBC proxy requires a number of supporting files to run. Download and extract the JDBC driver package that is provided with HCL® Quality Server. For more information, see HCL OneTest API tool packages.
-
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
andantlr-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
andantlr-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. - 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
-
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 thatcom.greenhat.jdbc.Driver
is listed first and that the other entries appended after are in a colon-separated list. -
Edit the
server
tag in theregistration.xml
file to the URL of the HCL® Quality Server installation that is being used.For information about modifying this file, refer to Modifying the configuration settings of the JDBC proxy.
-
Optional: Edit the
domain
andenvironment
tags in theregistration.xml
file.If these tags are modified, the JDBC Proxy is used only when recording/stubbing within the specified domain and environment.
- Run the Java™ application.
- Use HCL OneTest™ API and HCL® Quality Server to control JDBC recording and stubbing. For more information, see API Tester Reference and HCL OneTest Virtualization overview.