This section covers how to configure the Parasoft JDBC Driver for Tomcat. Configuration for Tomcat can be achieved via data source configuration or java.sql.Driver configuration. The best approach depends on how your application is configured.

Data Source Configuration

To configuring a Tomcat Data Source to use the Parasoft JDBC Driver:

  1. Copy the Parasoft JDBC Driver jar file to the global lib directory that is directly under tomcat root.
  2. Edit each context.xml file that contains the resource definition for the data source as follows (there may be several context.xml files to edit since they can be found in webapps as well as at the global config level):
    1. Modify type to the class name of the Parasoft Data Source you are going to use. The available values depend on the database vendor JDBC driver currently in use. See JDBC Driver Implementation Classes for details.
    2. Add factory and set it to com.parasoft.xtest.jdbc.virt.driver.ParasoftDataSourceFactory
    3. Set virtualizeServerUrl and virtualizeGroupId.
      For example:

      <Resource name="<original name>" auth="<original auth>"
      type="com.parasoft.xtest.jdbc.virt.driver.oracle.OracleDataSource" factory="com.parasoft.xtest.jdbc.virt.driver.ParasoftDataSourceFac-tory"
      virtualizeGroupId="hibernateOracle"
      virtualizeServerUrl="http://localhost.parasoft.com:9080"
      user="<original user>"
      password="<orignal password>"
      url="<original url>"/>

      The required properties (virtualizeGroupId and virtualizeServerUrl) are set on the resource as well. No system properties are needed.
      Do not change any fields starting with original (including url, name, user, and password). In the above case, the url field might be set to jdbc:oracle:thin:@//host:1521/db

java.sql.Driver Configuration

See JDBC Configuration for Standalone or Other Application Server Platforms.

Alternative Method: Calling the Original Data Source

You can call the original data source if it would be easier for you to reference the existing data source (e.g., if you have many options set) or if you are using a custom data source factory.
To configure a Tomcat Data Source to call the original data source:

  1. Copy the Parasoft JDBC Driver jar file to the global lib directory that is directly under tomcat root.
  2. In the server.xml or context.xml file, add a new resource with information to call the original data source.
    1. Modify the name of this resource to be the JNDI data source name that the AUT will call. This should be the name of the original data source. You can modify the original data source’s name to something like jdbc/nameLIVE [user defined].
    2. Add an attribute called targetDataSource. This will be the original data source and JNDI name. This is how the new datasource will call the original data source.
    3. Add a factory and set it to com.parasoft.xtest.jdbc.virt.driver.ParasoftDataSourceFactory.
    4. Set virtualizeServerUrl and virtualizeGroupId.

For example, assume you have this original data source:

<?xml version="1.0" encoding="UTF-8"?> 
<Context>
   <Resource name="jdbc/mysqlDBlive" auth="Container"
        type="javax.sql.DataSource" 
        username="12345" password="xxxxx" 
        driverClassName="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://boa.parasoft.com:3306/test" 
        maxActive="8"/>

Here is the equivalent Parasoft data source:

   <Resource name="jdbc/mysqlDB" auth="Container"
       factory="com.parasoft.xtest.jdbc.virt.driver.ParasoftDataSourceFactory"
       targetDataSource="jdbc/mysqlDBLive"
       virtualizeServerUrl="http://localhost:9080" 
       virtualizeGroupId="tomcat-target-data-source" 
       virtualizeServerPath="somePath"
       />
</Context>

Notes:

  • The required properties (virtualizeGroupId and virtualizeServerUrl) are set on the resource as well. No system properties are needed.
  • A recommended best practice is to add virtualizeServerPath to indicate which Virtualize server path the driver will send request information to. Once your asset is created, you will need to deploy it on that same path. This allows you to send data only to this single asset.
  • No labels