jmeter对数据的测试(2)

发表于:2013-05-27来源:博客园作者:qileilove点击数: 标签:jmeter
7.2 Adding JDBC Requests 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 selec
7.2 Adding JDBC Requests

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
 
7.3 Adding a Listener to View/Store the Test Results

The final element you need to add to your Test Plan is a Listener . This element is responsible for storing all of the results of your JDBC requests in a file and presenting a visual model of the data.

Select the JDBC Users element and add a Graph Results listener (Add --> Listener --> Graph Results).


Figure 7.7. Graph results Listener

原文转自:http://www.blogjava.net/qileilove/archive/2012/04/26/376675.html