zoukankan      html  css  js  c++  java
  • jmeter jdbc request使用详解

    1、在使用 jdbc request之前需要加载一个jar包

    在test plan中将jar包引入到classpath中

    2、创建一个JDBC Connection Configuration

      

    Variable Name: 变量名称,需要变量名绑定到池。需要唯一标识。与JDBC取样器中的相对应,决定JDBC取样的配置。简单理解就是在JDBC request的时候确定去哪个绑定的配置。

    MaxNumber of Connection: 数据库最大链接数

    PoolTimeout: 数据库链接超时,单位ms

    Idle Cleanup Interval (ms): 数据库空闲清理的间隔时间,单位ms

    Auto Commit:自动提交。有三个选项,true、false、编辑(自己通过jmeter提供的函数设置)

    Transaction Isolation:   

    事务间隔级别设置,主要有如下几个选项:(对JMX加解密) 

    TRANSACTION_REPEATABLE_READ事务重复读、TRANSACTION_READ_COMMITTED事务已提交读 、TRANSACTION_SERIALIZABLE事务序列化 、TRANSACTION_READ_UNCOMMITTED事务未提交读、TRANSACTION_NODE  事务节点 、DEFAULT默认、编辑

    Keep-Alive: 是否保持连接

    Max  Connection age (ms):最大连接时长,超过时长的会被拒绝

    Validation Query:验证查询,检验连接是否有效(数据库重启后之前的连接都失效,需要验证查询)

    Database URL:如jdbc:mysql://localhost:3306/test

    表示本地数据库,3306端口,数据库名称为test

    JDBCDriver Class: JDBC的类,如org.gjt.mm.mysql.Driver  

    3、创建  sampler - >jdbc request  

    variable 需要填写的内容与前面的 variable name bound to pool 的内容一致 

    Query Type- Set this according to the statement type: 
    • Select Statement
    • Update Statement - use this for Inserts and Deletes as well
    • Callable Statement
    • Prepared Select Statement
    • Prepared Update Statement - use this for Inserts and Deletes as well
    • Commit
    • Rollback
    • Autocommit(false)
    • Autocommit(true)
    • Edit - this should be a variable reference that evaluates to one of the above

    Parameter values : 参数

    Parameter types- Comma-separated list of SQL parameter types (e.g. INTEGER, DATE, VARCHAR, DOUBLE)

    Variable Names- Comma-separated list of variable names to hold values returned by Select statements, Prepared Select Statements or CallableStatement. Note that when used with CallableStatement, list of variables must be in the same sequence as the OUT parameters returned by the call. If there are less variable names than OUT parameters only as many results shall be stored in the thread-context variables as variable names were supplied. If more variable names than OUT parameters exist, the additional variables will be ignored.

    Result Variable Name- If specified, this will create an Object variable containing a list of row maps. Each map contains the column name as the key and the column data as the value. Usage:
    columnValue = vars.getObject("resultObject").get(0).get("Column Name");

    如果使用了select 结果有多条记录,需要对其中的某个结果进行操作:

    将结果存储在result中,result是以一个map形式进行的存储,需要对其中的某个数据进行操作的时候,可以在后面使用beanshellprocessor 

    上面的columnvalue就存储了某些数据,可以作为变量进行使用  如:${columnValue}

     http://www.cnblogs.com/yingchen/p/5124838.html

    第二种方法使用:

    A,B,C对应的是上面sql查出来的三个字段

    使用方法,在其他地方使用  ${A_#},${A_1},${A_2}分别表示,行数, 第一列,第一行,第一列第二行。

  • 相关阅读:
    JSP中Session的使用
    深入了解父类引用指向子类
    Gamma校正及其OpenCV实现
    cocos2d-x3.0之请求网络(phpserver)
    Quartz使用-入门使用(java定时任务实现)
    ExtJs--15--Ext.is*各种类型推断的方法,简单看源代码就能够明确了
    小谈边界问题
    VS2010旗舰版安装图解
    LSPCI具体解释分析
    兔子--gradle安装和配置
  • 原文地址:https://www.cnblogs.com/yingchen/p/5189040.html
Copyright © 2011-2022 走看看