【数据库报错系列】不建议不使用服务器身份验证建立SSL连接,必须默认建立SSL连接。

 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.

很长一段,看着头都大了,而且有这个错误就不会给你连接数据库,至少我连接失败是这个原因。

随后修改方式很简单

我们写数据库连接的时候加一段代码就行了

?autoReconnect=true&useSSL=false

原代码是这样的

String url = "jdbc:mysql://127.0.0.1:3306/db1"

修改后

String url = "jdbc:mysql://127.0.0.1:3306/db1?autoReconnect=true&useSSL=false"

然后就可以了,数据库的细节很多,也非常容易报错,每次错的原因也大多不同,假如我这个方法不管用请不要纠结,找下一个吧。

猜你喜欢

转载自blog.csdn.net/qq_63499305/article/details/130668665