MySQL和驱动版本均是5开头,本地测试连接druid运行正常,但是一到tomcat上控制台就报错。一直重复出现如下提示(还有一堆乱七八糟的)
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.
解决办法:在jdbc的url上加上:autoReconnect=true&useSSL=false
分析:产生这个错误的原因是MySQL在高版本(可是我才5的版本)需要指明是否进行SSL(保障Internet数据传输安全利用数据加密)
此时加完上述代码后还剩一个时区问题,即控制台会报如下提示
解决方案:url后加上 :serverTimezone=UTC
综上,最终格式如下:
<property name="url" value="jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=UTC"/>
三种颜色解决的问题分别是:中文乱码,指明ssl加密,时区问题
参考:https://blog.youkuaiyun.com/qq_37370132/article/details/107952021
https://blog.youkuaiyun.com/Camel_LT/article/details/109299205