如何使用JDBC请求在JMeter中设置存储过程的参数 [英] How to set up parameters of a stored procedure in JMeter using a JDBC Request

查看:671
本文介绍了如何使用JDBC请求在JMeter中设置存储过程的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用存储过程可调用语句来加载数据库.我在JMeter中创建的测试计划如下所示:

I am planning to load the database using a stored procedure callable statement. The test plan I am creating in JMeter looks like below:

- Test plan
  - Thread Group
     - JDBC Connection Configuration
     - JDBC Request
     - View results tree
     - Summary Report

  • JDBC连接配置基于已经起作用的测试. 问题出在我的JDBC请求中:
  • 变量名称:与JDBC连接配置中的数据库名称相同
  • 查询类型:Callable Statement
  • 查询: {call schema.dbpk_utilities.get_user_id(?,?,?,?,?,?,?)}
  • 参数值: S12345, HR, OUT, NULL,NULL,NULL, NULL
  • 参数类型:VARCHAR, VARCHAR, INTEGER, VARCHAR, VARCHAR, VARCHAR, VARCHAR
  • 变量名称:username,hr, id, four, five, six, seven
    • JDBC Connection Configuration is based on tests that already work. The question is with my JDBC Request:
    • Variable name: is the database name same as in JDBC Connection configuration
    • Query Type: Callable Statement
    • Query: {call schema.dbpk_utilities.get_user_id(?,?,?,?,?,?,?)}
    • Parameter values: S12345, HR, OUT, NULL,NULL,NULL, NULL
    • Parameter Types: VARCHAR, VARCHAR, INTEGER, VARCHAR, VARCHAR, VARCHAR, VARCHAR
    • Variable names: username,hr, id, four, five, six, seven
    • 我得到的错误是:

      Response message: java.lang.NumberFormatException: For input string:
      "OUT"
      

      谁能告诉我为什么回复消息?是否可以在JMeter中调用存储过程?我正在努力满足这个要求!

      Can anyone tell me why the response message? Is it possible to call Stored procedures in JMeter? I am struggling to OK this request!

      推荐答案

      按照上一篇文章的无空间规则",我发现了为什么请求使用java.lang.NumberFormatException进行响应的原因:对于输入字符串:"OUT"信息.见下文

      Following the 'no space rule' from the previous post I found out why the request was responding with java.lang.NumberFormatException: For input string: "OUT" message. See below

      变量名称: Oracle

      SQL查询:可调用语句

      查询:{致电nspishr.dbpk_user_utilities.get_user_details(?,?,?,?,?,?,?,?)}

      Query: {call nspishr.dbpk_user_utilities.get_user_details(?,?,?,?,?,?,?)}

      参数值: S12345,DMS,OUT,NULL,NULL,NULL,NULL

      Parameter Values: S12345,DMS,OUT,NULL,NULL,NULL,NULL

      参数类型: VARCHAR,VARCHAR,OUT INTEGER,VARCHAR,VARCHAR,VARCHAR,VARCHAR

      Par Types: VARCHAR,VARCHAR,OUT INTEGER,VARCHAR,VARCHAR,VARCHAR,VARCHAR

      变量名:用户名,dms,id,四个,五个,六个,七个

      Variable names: username,dms,id,four,five,six,seven

      请注意如何在此调用中注册参数.在我的程序中,参数1和参数2是IN参数.在我的情况下,通过为它们提供参数值S12345和HR可以隐式地使它们成为IN参数.

      Notice how the parameters are registered in this call. In my procedure param 1 and param 2 are IN parameters. These are made IN parameters implicitly by giving them a parameter value S12345 and HR in my case.

      从参数3一直到参数7都是OUT参数.参数4、5、6和7具有NULL值.因此,无需将它们注册为OUT参数.但是,参数3(ID)是OUT参数,必须通过在参数值中明确说OUT,然后在参数类型中声明OUT INTEGER 来进行注册.强>部分.要记住的是,您需要在参数值和参数类型中都指定OUT.不要忘记在参数类型字段中的参数数据类型.即OUT INTEGER,OUT VARCHAR ...

      From param 3 all the way to param 7 are OUT parameters. Param 4, 5, 6 and 7 have NULL values. Therefore no need to register them as OUT parameters. Param 3 (the id), however, is the OUT parameter and it has to be registered as such by explicitly saying OUT in the parameter value and then saying OUT INTEGER in the parameter types section. The thing to remember is that you need to specify OUT in both parameter value and parameter type. Not to forget the datatype of the parameter in the parameter types field. ie OUT INTEGER, OUT VARCHAR ...

      希望这会有所帮助

      这篇关于如何使用JDBC请求在JMeter中设置存储过程的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆