一.JDBC驱动的版本号以及名称问题

区别:

  com.mysql.jdbc.Driver 是 mysql-connector-java 5中的

  com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6以上的版本中的

注意,我这里使用的是springboot2.1.1版本,在pom.xml文件中整合mysql后自动引入的mysql-connector-java版本是8.x,因此需要使用com.mysql.cj.jdbc.Driver 这个驱动

如图:

    <!-- springboot版本-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <!-- 省略其他依赖--> <!-- mysql 这里没有显示的指定版本,默认集成的版本是8.x-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

注意:如果使用 com.mysql.jdbc.Driver,项目启动时,控制台会报错,表示该驱动已经过时

二.ServerTimeZone时区的问题

在设定时区的时候,如果设定serverTimezone=UTC,会比中国时间早8个小时,如果在中国,可以选择Asia/Shanghai或者Asia/Hongkong,例如:

url:jdbc:mysql://localhost:3306/mango?serverTimezone=Asia/Shanghai&useUnicode=true&zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=utf-8

注意:

   如果在url这里不设置时区,则可能报错

三.服务器直连mysq问题

不推荐不使用服务器身份验证来建立SSL连接。SSL – Secure Sockets Layer(安全套接层)

如果未明确设置,MySQL 5.5.45+, 5.6.26+ and 5.7.6+版本默认要求建立SSL连接。

为了符合当前不使用SSL连接的应用程序,verifyServerCertificate属性设置为’false’。或者使用autoConnect=true显示的支持直连
如果你不需要使用SSL连接,你需要通过设置useSSL=false来显式禁用SSL连接
如果你需要用SSL连接,就要为服务器证书验证提供信任库,并设置useSSL=true。

Jdbc Driver驱动和ServerTimeZone时区的的问题的更多相关文章

  1. com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的区别 serverTimezone设定

    转自: http://blog.csdn.net/superdangbo/article/details/78732700 com.mysql.jdbc.Driver 和 com.mysql.cj.j ...

  2. 异常: 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 configurat

    异常: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. ...

  3. 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

    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha ...

  4. 【转载】在使用JDBC连接MySql时报错: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

    在使用JDBC连接MySql时报错:You must configure either the server or JDBC driver (via the serverTimezone config ...

  5. You must configure either the server or JDBC driver (via the serverTimezone configuration property

    使用JDBC连接MySql时出现:The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one ...

  6. idea报错: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 configu

    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more tha ...

  7. 三、SpringBoot启动时JDBC报错:You must configure either the server or JDBC driver (via the serverTimezone configuration property)

    错误提示: Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connectio ...

  8. 连接数据库:ERROR: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 prop

    本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-conne ...

  9. 使用JDBC连接MySql时出现: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

    在连接字符串后面加上?serverTimezone=UTC 其中UTC是统一标准世界时间. 完整的连接字符串示例:jdbc:mysql://localhost:3306/test?serverTime ...

随机推荐

  1. 【学习】SpringBoot之全局异常处理器

    /** * 全局异常处理器 **/ @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(Exceptio ...

  2. [翻译]扩展C#中的异步方法

    翻译自一篇博文,原文:Extending the async methods in C# 异步系列 剖析C#中的异步方法 扩展C#中的异步方法 C#中异步方法的性能特点. 用一个用户场景来掌握它们 在 ...

  3. Hive SQL 语法学习与实践

    Hive 介绍 Hive 是基于Hadoop 构建的一套数据仓库分析系统,它提供了丰富的SQL查询方式来分析存储在Hadoop 分布式文件系统中的数据,可以将结构化的数据文件映射为一张数据库表,并提供 ...

  4. java代码如何在没有安装JDK的Windows下运行

    java代码如何在没有安装JDK的Windows下运行? 对于Java桌面应用来说,比较烦琐的就是安装部署问题,如:客户端是否安装有jre.jre版本.jre在哪里下载.如何用jre启动Java应用等 ...

  5. 后盾网lavarel视频项目---3、lavarel中子控制器继承父控制器以判断是否登录

    后盾网lavarel视频项目---3.lavarel中子控制器继承父控制器以判断是否登录 一.总结 一句话总结: 在common控制器的构造方法中验证登录中间件,其它的控制器继承common控制器 p ...

  6. Python学习笔记:字典型的数据结构

    根据书上的定义,字典是将数据与键相关联,这个键相当于是一组数据的一个名称,键必须是唯一的. python中提供了内置的映射类型--字典.映射其实就是一组key和value以及之间的映射函数,其特点是: ...

  7. 三十一:数据库之SQLAlchemy属性常用数据类型和Column常用参数

    SQLAlchemy属性常用数据类型 Column常用参数

  8. 配置pip镜像源(转)

    使用pip安装python扩展时,如若没有配置国内镜像源,在未翻墙的情况下,其下载速度将会特别缓慢.因此,有些时候我们必须使用国内镜像源,来解决pip下载安装速度慢的问题,比较常用的国内镜像包括: 阿 ...

  9. Nginx正向代理、反向代理、负载均衡及性能优化

    一.Nginx是什么 Nginx是一款高性能的 HTTP 和反向代理服务器,由俄罗斯人Igor Sysoev(伊戈尔·赛索耶夫)为俄罗斯网站Rambler.ru开发的,在Rambler.ru网站平稳的 ...

  10. Python学习之==>条件判断

    1.单条件判断 # 接收输入的值,使用input函数,用input接收输入的值都是string类型的 age = input('请输入你的年龄:') age = int(age) # 类型转换,转换成 ...