驱动版本问题:connect error, url mysql.db.url:jdbc:mysql://IP地址:3306/数据库名

MySQL升级版本 5.7.43

必须升级驱动版本 8.0 以上版本

启动项目报错

使用Druid数据库连接池获取Mysql常见的错误--不兼容问题

后来百度搜索发现原来是Mysql版本和mysql-connector-java版本不一致造成的。

查询Mysql版本号:

SELECT version();

然后去官网找对应版本mysql-connector-java

下载解压后就能找到对应的mysql-connector-java-8.0.11.jar将这个jar包拖金IDEA,右键点击它,然后选择add as a library

再次运行测试文件,发现还是抛出了NullPointerException异常:

Establishing SSL connection without server's identity verification is

not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+

requirements SSL connection must be established by default if explicit

option isn't set. For compliance with existing applications not using

SSL the verifyServerCertificate property is set to 'false'. You need

either to explicitly disable SSL by setting useSSL=false, or set

useSSL=true and provide truststore for server certificate

verification.

以上报错信息来看、大概意思就是不建议在没有服务器身份验证的情况下建立SSL连接

此时我们需要在url后面加两个个参数useSSL=false,用?与数据库的url隔开,两个参数之间用&隔开

如:jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC

(jdbc.properties配置文件中的url也改成上面的)

之后我们再次运行mysql.java文件,发现已经可以正常连接到数据库。

相关推荐
咚咚王者14 小时前
MySQL 导出脚本
android·mysql·adb
禹凕14 小时前
MYSQL——基础知识(SQL事务)
sql·mysql
汽车仪器仪表相关领域14 小时前
Kvaser Leaf Light HS v2 CB:裸卡式CAN接口新标杆,赋能车载与工业集成测试高效升级
服务器·网络·数据库·人工智能·单元测试·自动化·汽车
l1t14 小时前
试用支持postgresql wire协议的duckdb服务器duckgres
服务器·数据库·postgresql
明天,今天,此时14 小时前
表格形式的数据库表的元数据与SQL字符串互转
数据库·sql·mysql转hivesql·表格形式转sql形式
\xin14 小时前
Pikachu的python一键exp,xx型注入,“insert/updata“注入,“delete“注入,“http header“注入
数据库·python·http
of Watermelon League14 小时前
Redis 下载与安装 教程 windows版
数据库·windows·redis
coNh OOSI14 小时前
如何在 Windows 上安装 MySQL(保姆级教程2024版)
数据库·windows·mysql
Chasing__Dreams14 小时前
Redis--基础知识点--31--集群哈希槽为什么是16384?
数据库·redis·哈希算法
SeSs IZED14 小时前
MySQL中查看表结构
数据库·mysql·oracle