Jmeter 连接JDBC

1. 下载 mysql-connector-java-8.0.11.jar

版本参考:https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-versions.html

下载地址:https://repo1.maven.org/maven2/mysql/mysql-connector-java/

2. 添加数据库jar包

拷贝mysql驱动包到jmeter/lib目录下
或者
在测试计划处添加驱动jar包


image.png

3. 添加一个线程组以及JDBC Request

image.png

4. 添加JDBC Connection Configuration

image.png

Variable Name for created pool:自定义连接池名称
Database URL:jdbc:mysql://{ip}:{port}/{dbname}?useUnicode=true&characterEncoding=utf8
JDBC driver class:JDBC驱动
Username:数据库用户名
Password:数据库密码

Datebase Driver class Database URL
MySQL com.mysql.jdbc.Driver jdbc:mysql://host:port/{dbname}
PostgreSQL org.postgresql.Driver jdbc:postgresql:{dbname}
Oracle oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:user/pass@//host:port/service
Ingres (2006) ingres.jdbc.IngresDriver jdbc:ingres://host:port/db[;attr=value]
MSSQL com.microsoft.sqlserver.jdbc.SQLServerDriver或者net.sourceforge.jtds.jdbc.Driver jdbc:sqlserver://IP:1433;databaseName=DBname或者jdbc:jtds:sqlserver://localhost:1433/"+"library"

image.png

如果遇到如下报错:
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
image.png

image.png
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。