JMeter 连接数据库报错信息整理

目录

1.SSL连接问题

2.驱动版本报错

[3.缺少 mysql-connector 驱动问题](#3.缺少 mysql-connector 驱动问题)

4.时区问题

5.'com.mysql.jdbc.Driver'被弃用问题


1.SSL连接问题

这是以前遇到的问题,mysql 版本是 5.7.42,jmeter 下载的mysql-connector 驱动是 8.0.11,连接数据库的信息都是正确的,但是在查询数据的时候报错"Cannot create PoolableConnectionFactory(Communications link failure The last packet successfully received from the server was 31 milliseconds ago. The last packet sent successfully to the server was 31 milliseconds ago.)"。一开始怀疑驱动版本过高,将mysql-connector 驱动换成 5.1.42,错误仍然没有解决,后来在 url 连接的后面加上"?useSSL=false",禁用SSL连接,完美解决报错问题。

2.驱动版本报错

对于驱动版本报错的,主要是"Cannot create PoolableConnectionFactory (Could not create connection to database server.)",这是我之前遇到的,当时的情况是 jmeter 版本是3.1,mysql版本是 8.0,而 mysql-connector-java 版本是 5.1.31,后来换成高版本的驱动之后,可以正常连接数据库,并能正常读写数据。

3.缺少 mysql-connector 驱动问题

连接数据库时还有另外一种报错"Cannot load JDBC driver class 'com.mysql.jdbc.Driver' ",这就是典型的缺少 mysql-connector 驱动,解决办法就是下载一个对应版本的驱动,下载地址:https://dev.mysql.com/downloads/connector/j/,将解压出来的 jar 包放到 jmeter\lib 目录下,重启 jmeter 即可。

4.时区问题

数据库连接正常,驱动和数据库版本都一致,执行后报错"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是统一标准世界时间。

5.'com.mysql.jdbc.Driver'被弃用问题

还有一种错误:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

这是因为数据库驱动:'com.mysql.jdbc.Driver'被弃用,将驱动改为com.mysql.cj.jdbc.Driver即可(需要手动编辑)

以上是自己在工作中遇到的几个连接数据库的问题,欢迎小伙伴们参考,也欢迎大家补充交流!

相关推荐
寻星探路1 小时前
【深度长文】万字攻克网络原理:从 HTTP 报文解构到 HTTPS 终极加密逻辑
java·开发语言·网络·python·http·ai·https
陌上丨3 小时前
Redis的Key和Value的设计原则有哪些?
数据库·redis·缓存
曹牧3 小时前
Spring Boot:如何测试Java Controller中的POST请求?
java·开发语言
AI_56783 小时前
AWS EC2新手入门:6步带你从零启动实例
大数据·数据库·人工智能·机器学习·aws
ccecw4 小时前
Mysql ONLY_FULL_GROUP_BY模式详解、group by非查询字段报错
数据库·mysql
JH30734 小时前
达梦数据库与MySQL的核心差异解析:从特性到实践
数据库·mysql
数据知道4 小时前
PostgreSQL 核心原理:如何利用多核 CPU 加速大数据量扫描(并行查询)
数据库·postgresql
爬山算法4 小时前
Hibernate(90)如何在故障注入测试中使用Hibernate?
java·后端·hibernate
kfyty7254 小时前
集成 spring-ai 2.x 实践中遇到的一些问题及解决方案
java·人工智能·spring-ai
猫头虎4 小时前
如何排查并解决项目启动时报错Error encountered while processing: java.io.IOException: closed 的问题
java·开发语言·jvm·spring boot·python·开源·maven