折磨我半天的bug(MySQL-JDBC)——You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

原因大概是MySQL的版本是8.0,而我使用的MySQL驱动版本较低(5.1.40版本)

存在驱动mysql-connector-java兼容问题,导致一直报该错误,直到我尝试升级MySQL驱动mysql-connector-java(8.0.20版本)之后,问题总算解决。

参考链接:https://blog.csdn.net/AOBO516/article/details/93370637#%E5%8D%87%E7%BA%A7MySQL%E9%A9%B1%E5%8A%A8mysql-connector-java%E5%8D%87%E7%BA%A7%E5%88%B08.0.X%E7%89%88%E6%9C%AC

 

然后又出现了新的问题:

java.sql.SQLException: 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.

新版本JDBC驱动类的“com.mysql.jdbc.Driver”已经过时了,改成“com.mysql.cj.jdbc.Driver”了。说我没有配置时区,查了一下,原来从JDBC6.0开始驱动类使用了新的,并且url中必须要设置时区,否侧会报错。那按照规定改就行了。

解决方法:在url的最后添加?serverTimezone=UTC(UTC表示标准时区)

参考链接:https://blog.csdn.net/q1406689423/article/details/89845338

 

折磨我半天的bug(MySQL-JDBC)——You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

上一篇:mysql数据类型


下一篇:sql server日志已满报错