记录:mysql8版本中引入的问题

mysql 8版本中引入时出现的一些异常记录

今日使用逆向工程时由于mysql版本为8版本出现了一些异常,逐一排查解决,对已出现的问题及解决方案进行记录,希望有所帮助。
如果你安装的版本为mysql的8版本则在pom.xml中将mysql的依赖版本改为如下所示。

   <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>

在使用驱动时,将驱动改为如下所示,由于我是在xml中使用,具体代码如下:

 <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/foodie-shop?&amp;autoReconnect=TRUE&amp;useSSL=FALSE&amp;serverTimezone=GMT"
                        userId="root"
                        password="password">
        </jdbcConnection>

问题一:

初试时由于xml里面 IDEA 将"&"符号当做了特殊字符。出现了下述异常。

Unescaped & or nonterminated character/entity reference

解决方案:
如上述代码显示将"&" 该换成"&amp;"即可。

问题二:

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.

出现上述异常的原因是Mysql在高版本中需要指定是否需要进行SSL连接。
解决方案:
我们在URL引入时,添加useSSL=FALSE即可。

connectionURL="jdbc:mysql://localhost:3306/foodie-shop?&amp;autoReconnect=TRUE&amp;useSSL=TRUE&amp;serverTimezone=GMT"

由于证书问题,上述中如果将useSSL=TRUE会产生如下的错误。

java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors

问题三:

java.sql.SQLNonTransientConnectionException: Could not create
connection to database server. Attempted reconnect 3 times. Giving up.

出现上述问题的原因是需要在使用时,设定时区才可以正常链接。

解决方案:
在url引入时,添加serverTimezone=GMT即可解决问题。

connectionURL="jdbc:mysql://localhost:3306/foodie-shop?&amp;autoReconnect=TRUE&amp;useSSL=FALSE&amp;serverTimezone=GMT"

此上所述,即完成了Mysql 8版本在逆向工程中的引入。如果仍然未能解决,请检查:

  1. 配置文件的url,userName,passWord是否正确。
  2. 检查MySQL服务是否运行。
    如果仍未能解决,请下方留言。
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值