Now that we have defined our users, it is time to define the tasks that they will be performing. In this section, you will specify the JDBC requests to perform.
Begin by selecting the JDBC Users element. Click your right mouse button to get the Add menu, and then select Add --> Config Element --> JDBC Connection Configuration. Then, select this new element to view its Control Panel (see Figure 7.3).
Set up the following fields (these assume we will be using a local MySQL database called test):
-
Variable name bound to pool. This needs to uniquely identify the configuration. It is used by the JDBC Sampler to identify the configuration to be used.
-
Database URL: jdbc:mysql://localhost:3306/test
-
JDBC Driver class: com.mysql.jdbc.Driver
-
Username: guest
-
Password: password for guest
The other fields on the screen can be left as the defaults.
JMeter creates a database connection pool with the configuration settings as specified in the Control Panel. The pool is referred to in JDBC Requests in the 'Variable Name' field. Several different JDBC Configuration elements can be used, but they must have unique names. Every JDBC Request must refer to a JDBC Configuration pool. More than one JDBC Request can refer to the same pool.
Figure 7.3. JDBC Configuration |
Selecting the JDBC Users element again. Click your right mouse button to get the Add menu, and then select Add --> Sampler --> JDBC Request. Then, select this new element to view its Control Panel (see Figure 7.4).
Figure 7.4. JDBC Request |
In our Test Plan, we will make two JDBC requests. The first one is for Eastman Kodak stock, and the second is Pfizer stock (obviously you should change these to examples appropriate for your particular database). These are illustrated below.
JMeter sends requests in the order that you add them to the tree. |
Start by editing the following properties (see Figure 7.5):
-
Change the Name to "Kodak".
-
Enter the Pool Name: MySQL (same as in the configuration element)
-
Enter the SQL Query String field.
Figure 7.5. JDBC Request for Eastman Kodak stock |
Next, add the second JDBC Request and edit the following properties (see Figure 7.6):
-
Change the Name to "Pfizer".
-
Enter the SQL Query String field.
Figure 7.6. JDBC Request for Pfizer stock |