jdba访问mysql,如何通过JMeter中的JDBC采样器运行多个MySQL语句

I am using JDBC sampler in JMeter 2.13.

I have around 100 delete statements in my JMeter sampler like below:

delete from abc where id >= ${Variable_Name};

delete from qwe where id >= ${Variable_Name};

delete from xyz where id >= ${Variable_Name};

Problem is that when I run a single statement in JDBC sampler, it works fine. But when ever I try to run 2 or more than 2 statements from my JDBC sampler. It always throws error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'delete from qwe where id >= 1;

Can someone please mention a workaround it? and how I can overcome this problem.

解决方案

It seems you cannot execute multiple statements in a single JDBC Request element.

I had a similar situation where I needed to execute some clean up statements on the database before proceeding with the rest of the tests. I was able to achieve this by reading the SQL statements from an external file, using CSV Data Set Config nested in a Loop Controller, in a separate setUp Thread Group.

The elements were placed like this:

TJbyb.png

And I used the following configurations:

Loop Controller

Loop Count: Forever

CSV Data Set Config

Filename: /path/to/multiple-statements.sql

Variable Name: STMT

Recycle on EOF: False

Stop thread on EOF: True

JDBC Request

Query: ${STMT}

The Loop Controller is set to run forever, as the stop condition is set on the CSV Data Set Config. Each iteration will read one line of the file, set the variable STMT, then JDBC Request will execute the query ${STMT}.

When the end-of-file is reached, the setUp Thread Group will stop and the core test Thread Group will proceed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值