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");