jmeter连接并使用mysql数据

1、测试计划(Test Plan)下面把jdbc驱动包导入。
jmeter连接并使用mysql数据

2、线程组下添加一个配置元件JDBC Connection Configuration。
jmeter连接并使用mysql数据
Variable Name:自定义参数,在JDBC Request中会用到;

Database URL:jdbc:mysql:// 数据库IP地址:数据库端口/数据库名称;

JDBC Driver Class:com.mysql.jdbc.Driver;

Username:数据库用户名;

Password:数据库密码;

3、在添加一个Sampler:JDBC Request,顺手加个结果树。

jmeter连接并使用mysql数据

--------------------------------------分割线---------------------------------------

上述过程中,执行之后结果树中出现了一个报错:Cannot create PoolableConnectionFactory (The server time zone value ‘???��������??��??’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.)

解决方法如下:
jmeter连接并使用mysql数据

在database url后面加上**?serverTimezone=UTC**,其中UTC是统一标准世界时间。

解决中文乱码输入问题,可以在database url后面加上?useUnicode=true&characterEncoding=UTF-8。