JDBC连接Mysql出现的问题

报错信息:
Tue Jul 16 16:08:17 CST 2019 WARN: 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.

Mysql版本:5.7
jdk:1.8

原因:根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果不设置显式选项,则必须建立默认的SSL连接。需要通过设置useSSL=false来显式禁用SSL,
解决方案:

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/JDBC?useSSL=false","root","root");//在数据库名后加上?useSSL=false

posted @ 2019-07-16 16:14  Zcc的Blog  阅读(294)  评论(0编辑  收藏  举报