校园商铺-2项目设计和框架搭建-8升级mysql驱动相关的配置以支持mysql8

1.如何升级驱动

1.1步骤:

a 确保当前程序能正常访问数据库
b 更新mysql驱动重新运行程序进行校验
maven依赖https://mvnrepository.com/artifact/mysql/mysql-connector-java/8.0.17

<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.17</version>
</dependency>

重新运行测试脚本

1.2问题:

1.Caused by: com.mysql.cj.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.
错误原因分析:这是因为mysql 服务器时区问题导致的。
解决方案一:

<!--直接在url后面添加UTC或者GMT:-->
&serverTimezone=UTC
&serverTimezone=GMT
<!--指定GMT+8时区:-->
serverTimezone=GMT%2B8

解决方案二:

-- 查看当前mysql服务器时区语句:
show variables like '%time_zone%';
-- 修改time_zone的值为+8:00语句:
set global time_zone='+8:00';

参考:http://www.sohu.com/a/320708874_418879
问题2: Loading class 'com.mysql.jdbc.driver',This is deprecated.The new driver class is 'com.mysql.cj.jdbc.Driver'.
driver过时了,新的driver是com.mysql.cj.jdbc.Driver,替换即可
jdbc.properties

jdbc.driver=com.cj.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/o2o?useUnicode=true&characterEncoding=utf8&GMT%2B8
jdbc.username=root
jdbc.password=123456

2.为什么大公司喜欢用旧版本

  • 1.稳定大于一切,不能用自己的业务为新技术充当小白鼠。新版本未经市场考验,在实际使用中,可能存在很多bug。
  • 2.老版本积累了现成的经验,便于问题得到快速定位解决
  • 3.升级成本可能大,设计者需要考虑兼容,接口往往不变
  • 4.和经典书记一样,稳定版本具备学习价值,一通百通

3.如何选择合适的JDK版本进行学习

选择oracle长期支持的版本进行学习,推荐JDK8(支持到2025年)和JDK11(支持到2026年)

4.利用百度等搜索引擎来解决60%的问题

猜你喜欢

转载自www.cnblogs.com/csj2018/p/11563234.html
今日推荐