mysql获取连接connection失败

好久不写jdbc了,今天写了个小东西,数据库连接失败,错误信息如下:

java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more

无法识别或代表多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。mysql返回的时间有问题,比实际时间早8小时,解决方案:在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8

错误信息2:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdb

加载类“com.mysql.jdbc.Driver” 。这已被弃用。新的驱动程序类是`com.mysql.cj.jdbc.Driver' 驱动程序通过SPI自动注册,通常不需要手动加载驱动程序类。

警告信息:

 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.

建立无服务器的身份验证SSL连接不推荐使用。根据MySQL 5.5.45 +,5.6。 26+和5.7.6+的要求,如果未设置显式选项,则必须默认建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为'false'。您需要通过设置useSSL = false显式禁用SSL,或者设置useSSL = true并为服务器证书验证提供信任库。

此警告出现的时候MySQL说明已经安装成功了,这是警告不是错误,以后使用是不影响的。意思就是说建立ssl连接,但是服务器没有身份认证,这种方式不推荐使用。

猜你喜欢

转载自www.cnblogs.com/zwakeup/p/9363634.html