mysql8 JDBC使用问题
驱动程序的描述字符串
Establishing SSL connection without server’s identityverification 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 optionisn’t set. For compliance with existing applications not using SSL theverifyServerCertificate property is set to ‘false’. You need either toexplicitly disable SSL by setting useSSL=false, or set useSSL=true and providetruststore for server certificate verification.
驱动程序的描述字符串com.mysql.jdbc.Driver是mysql5.0及以前的老写法
而mysql6.0以后的需要这样写com.mysql.cj.jdbc.Driver
MySQL在高版本需要指明是否进行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.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.
在mysql连接字符串url中加入ssl=true或者false即可,如下所示
"jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong"
serverTimezone=HongKong 是设置时区,可以填UTC、Asia/Shanghai等等,UTC要比中国时区早8个小时。