JDBC Data Source

Applies to ReadyAPI 3.52, last modified on April 25, 2024

The JDBC data source gets data from the database by using the connection specified in the test step. The data source can either use a project database connection, or a connection specified only for the data source.

The data source assigns values to the properties by matching the names of the database columns or aliases.

In this topic, we focus on how to configure the JDBC data source. We assume you are already familiar with data-driven testing and how to configure a data-driven loop. Otherwise, please read Basic Concepts of Data-Driven Testing, or complete some of our tutorials before you continue.

To use the JDBC data source, you must install a database driver. See Installing Database Drivers for complete information.

You can use data sources of the JDBC type in the Data Source test step in functional tests, and in virtual services.

Configuration

The JDBC data source

Click the image to enlarge it.

Properties

A table containing properties for the data source.

Prepared Properties

A table that contains prepared properties used in the SQL Query. To learn how to work with prepared properties, see Prepared Properties.

Connection

Specifies the name of a database connection. Specify None to use a connection specified in the data source.

Configure

Opens the Database configuration dialog to modify the selected database connection.

Driver

Specifies the used database driver if the Connection option is set to None.

Note: This field supports property expansions.

Connection String

Specifies the used connection string if the Connection option is set to None.

Note: This field supports property expansions.

Password

Specifies the password to access the database if the Connection option is set to None.

Due to the specifics of the MySQL Connector/J drivers, when you work with MySQL or MariaDB databases, you have to manually percent-encode all the reserved URL characters (for example, /, :, @, (, ), [, ], &, #, =, ?, and space) that appear in your password. For example, if your password is p@ssw?rd, you must enter it as p%40ssw%3Frd.

To learn about percent-encoding, see https://www.w3schools.com/tags/ref_urlencode.asp.

Configure

Opens the Database configuration dialog to modify the connection.

Test Connection

Tries to connect to the database by using the specified connection settings.

SQL Query

Specifies the query to the database. To use a test step parameter in the query, specify the name of the desired parameter with the leading colon character (:parameter). You can specify the desired query manually or by using the Build SQL Query or Create Query dialog.

Currently, you cannot use SQL queries with the double-colon (::) syntax.
Note: This field supports property expansions.

Fetch Size

Specifies the number of rows obtained in one database roundtrip.

Due to the specifics of the MySQL Connector/J drivers, when you work with MySQL databases, you can specify only the -2147483648 value to obtain one row in a roundtrip. Other values are ignored.

Stored Procedure

Select this option if your query is a call to a stored procedure. In this case, you specify the name of the stored procedure and its parameters in the SQL Query field.

The passed parameters must be in the same order as they are declared in the database.

ReadyAPI assigns values obtained from database columns to properties with the same names. For example, it assigns the data from the “Order” column to the “Order” property.

Example

Use a Wizard

Opens a dialog to specify an SQL Query. If the Stored Procedure option is enabled, it opens the Create Query dialog, otherwise – the Build SQL Query dialog.

See Also

Installing Database Drivers
Prepared Properties
Query Wizard
Data Source Types
Data Source Loop Test Step

Watch the video
 
Highlight search results