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即可(需要手动编辑)

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

相关推荐
longerxin202016 小时前
MongoDB 在线安装-一键安装脚本(CentOS 7.9)
数据库·mongodb·centos
失散1316 小时前
分布式专题——9 Redis7底层数据结构解析
java·数据结构·redis·分布式·缓存·架构
馨谙16 小时前
设计模式之单例模式大全---java实现
java·单例模式·设计模式
程序员TNT16 小时前
Shoptnt 安全架构揭秘:JWT 认证与分布式实时踢人方案
java·redis·分布式·架构
水无痕simon16 小时前
3 水平分表
java·数据库
文人sec16 小时前
性能测试-jmeter10-分布式测试
分布式·jmeter·性能优化·模块测试
恣艺16 小时前
探索数据库世界:从基础类型到实际应用
数据库
野生程序员y16 小时前
深入解析Spring AOP核心原理
java·后端·spring
阿萨德528号16 小时前
ZooKeeper Java客户端与分布式应用实战
java·zookeeper·java-zookeeper
死也不注释16 小时前
【Unity UGUI 交互组件——Dropdown(TMP版本)(10)】
java·unity·交互