Jmete连接Mysql数据库

  昨天把Mysql装好了,这个躺在草稿中很久的文章也可以出炉了。

首先需要准备个Mysql jdbc驱动包,尽量保证其版本和你的数据库版本一致,至少不低于数据库版本,否则可能有问题。去官网扒一个下来吧:https://dev.mysql.com/downloads/connector/j/

1、测试计划(Test Plan)下面把jdbc驱动包导入。

2、线程组下添加一个配置元件JDBC Connection Configuration。

Variable Name:自定义参数,在JDBC Request中会用到;

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

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

Username:数据库用户名;

Password:数据库密码;

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

  上述过程中,执行之后结果树中出现了一个报错:java.sql.SQLException: 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.)

解决如下:

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

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

猜你喜欢

转载自www.cnblogs.com/zichuan/p/9186274.html