gpt4 book ai didi

mysql - 如何在 JMeter 中通过 JDBC 采样器运行多个 MySQL 语句

转载 作者:可可西里 更新时间:2023-11-01 07:56:03 24 4
gpt4 key购买 nike

我在 JMeter 2.13 中使用 JDBC 采样器。

我的 JMeter 采样器中有大约 100 个删除语句,如下所示:

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

问题是当我在 JDBC 采样器中运行单个语句时,它工作正常。但是每当我尝试从我的 JDBC 采样器运行 2 个或 2 个以上的语句时。它总是抛出错误。

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;

有人可以提出解决方法吗?以及我该如何克服这个问题。

最佳答案

您似乎无法在单个 JDBC Request 元素中执行多个语句。

我遇到过类似的情况,我需要在继续进行其余测试之前对数据库执行一些清理语句。我能够通过使用嵌套在 Loop Controller 中的 CSV Data Set Config 从外部文件读取 SQL 语句来实现这一点,在一个单独的 setUp Thread Group 中。

元素是这样放置的:

setup database before test example

我使用了以下配置:

循环 Controller

  • 循环计数:永远

CSV 数据集配置

  • 文件名:/path/to/multiple-statements.sql
  • 变量名:STMT
  • 在 EOF 上回收:False
  • 在 EOF 时停止线程:True

JDBC 请求

  • 查询:${STMT}

Loop Controller 设置为永远运行,因为在 CSV Data Set Config 上设置了停止条件。每次迭代将读取文件的一行,设置变量STMT,然后JDBC Request将执行查询${STMT}

当到达文件末尾时,setUp Thread Group 将停止,核心测试Thread Group 将继续。

关于mysql - 如何在 JMeter 中通过 JDBC 采样器运行多个 MySQL 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34133362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com