使用新版本mysql-connector-java异常解决

  最近按正常的方法搭建SSM框架,无法正常启动Tomcat出现如下异常信息:

 

com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: 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.

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

 

  发现是由于使用了最新的mysql连接jar包(mysql-connector-java-6.0.6)导致的:

  一开始最配置的数据库url信息如下:

      db.url=jdbc:mysql://localhost:3306/permission?useUnicode=true&characterEncoding=UTF-8

  修复方法:数据库连接的url上加上&serverTimezone=GMT

 

  即变更为db.url=jdbc:mysql://localhost:3306/permission?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT

 

  解决掉该问题后启动tomcat,发现又疯狂打印如下日志

 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.

Wed Dec 06 21:49:08 CST 2017 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

 

  解决办法:添加&useSSL=false

     db.url=jdbc:mysql://localhost:3306/permission?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT&useSSL=false

 

  接着用mybatis-generator自动生成数据库相关文件时,又出现如下错误:

Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (default-cli) on project permission: Column name pattern can not be NULL or empty.

 

  解决办法:添加&nullNamePatternMatchesAll=true

 

  最后的数据库连接的地址如下,启动Tomcat正常运行:

jdbc:mysql://localhost:3306/permission?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=GMT&nullNamePatternMatchesAll=true

      OK,完工,可以正常使用了

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值