Page tree

Skip to end of metadata
Go to start of metadata

This topic introduces the Parasoft JDBC Driver, which is used to record database queries along with their corresponding resulting data. Once the Parasoft JDBC Driver is configured and the AUT is set up to communicate with it, you can use the JDBC Controller to switch modes (e.g., passthrough, record, virtualize) from the UI without having to restart the application server.

Sections include:

Parasoft JDBC Driver Introduction

Database virtualization (described in Recording Databases) is performed using the Parasoft JDBC Driver along with the JDBC Controller. The Parasoft JDBC Driver is a special JDBC driver that can act as a man-in-the-middle between the application and its regular JDBC driver. It implements the JDBC APIs, which allows it to be configured into Java application servers just like any standard database driver.

Once configured, the driver can:

  • Delegate JDBC calls (SQL queries) to the original driver—and optionally send the queries and their associated ResultSets to Parasoft Virtualize Server to be recorded. With failover mode, queries will be automatically rerouted to Parasoft Virtualize Server if a failure (SQL exception) occurs with the live database.
  • Delegate the queries to a Parasoft Virtualize Server, which can in turn (once a SQL Responder in a virtual asset is configured) respond to the queries in the same manner as the original database connection. With hybrid mode, queries will be automatically delegated to the original driver if no matching "virtual" responses are found.

Controlling the Parasoft JDBC Driver Remotely

Through the Virtualize UI (or Environment Manager UI), you can use JDBC Controllers to control the settings of a single Parasoft JDBC Driver or a group of drivers. For instance, you can have a single point of control for a JDBC drivers deployed on clustered environments. Or, if you have multiple drivers (or data sources) used within a single AUT, you can orchestrate their deployment configuration in unison (e.g., you can have them all switch modes simultaneously).

Using the UI controls, you can change the mode (record, passthrough, virtualize, hybrid, failover) and other Parasoft JDBC Driver settings (such as logging) without having to restart the AUT. If you change settings while the AUT is offline, those changes will be applied upon startup.

Supported SQL Queries

Parasoft Virtualize supports the recording and virtualization of SQL SELECT statements. Stored procedures and function with multiple in, out and inout parameters are supported, including Cursor/ResultSet parameters. For Oracle and DB2, recording stored procedures that have multiple out parameters that each return a cursor is supported.

When queries are being routed to the actual JDBC driver (i.e., during recording or passthrough mode), INSERT, UPDATE and DELETE queries are delegated to the original database/driver.

When queries are being sent to a virtual asset, calls on Statement.executeUpdate() will return the value 0; Parasoft Virtualize will not emulate the actual behavior of INSERT, UPDATE and DELETE statements. As a result, any data that is recorded into Virtualize will not be modified by these SQL queries.

Conditions for Recording the Data

Results are recorded either when the CallableStatement is closed or when all the declared out parameters and results sets have been read in. For ResultSets to be recorded, close must be called on them. Calling close on Statement or PreparedStatement will mean that no data will be recorded from the ResultSet. Recorded column names are based upon the interface method used to retrieve them. Calling ResultSet.getString(String columnLabel) will use the columnLabel in the recorded data. If a column index is used, the recorded data will use the index number as the column label.

When a result set is not closed by an explicit call to ResultSet.close(), results will be recorded when the Parasoft JDBC Driver stops recording. When recording stops, the Parasoft JDBC Driver will check for any result set data that wasn't closed explicitly, then submit them to the Virtualize Server to be recorded.

Stored Procedures

Stored procedures are supported by Virtualize and the Parasoft JDBC Driver through the CallableStatement interface. Virtualize will emulate the return and out parameter values of a stored procedure without any visibility into its implementation. If the stored procedure performs UPDATE, INSERT or DELETE queries, data recorded in Virtualize will not be affected by such queries.

Functions/procedures that return a single ResultSet (either as an out parameter or as the function return value) are supported.

The following are not currently supported:

  • Functions/procedures that return multiple out parameters that are ResultSets.
  • Functions/procedures that return a result set and an out parameter(s) that are ResultSets.
  • No labels