zoukankan      html  css  js  c++  java
  • mysql驱动参数变化

    在java平台使用的mysql jdbc驱动为:mysql-connector-java。
    在项目中添加如下依赖:

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${version.mysql.connector}</version>
    </dependency>
    

    在6.0.2版本之前

    driver=com.mysql.jdbc.Driver
    url=jdbc:mysql://host:port/dbname?characterEncoding=utf8
    

    在6.0.2版本之后

    driver=com.mysql.cj.jdbc.Driver
    url=jdbc:mysql://host:port/dbname?characterEncoding=utf8&serverTimezone=UTC
    

    mysql-connector-java参数变化

    1.从6.0.2版本开始,驱动类不再是com.mysql.jdbc.Driver,需要配置为:com.mysql.cj.jdbc.Driver
    否则,在启动时会提示警告日志:

    Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
    

    2.从6.0.2版本开始,如果mysql server未明确配置时区,则必须在jdbc连接参数中设置serverTimezone
    否则,在启动时报错:

    Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database.  Cause: 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.
    
  • 相关阅读:
    Spring boot mybatis : Error creating bean with name 'com.github.pagehelper.autoconfigure.MapperAutoConfiguration': Invocation of init method failed;
    方法调用
    初识MQ
    Shell 变量
    Eclipse 导入本地 Git 项目
    IDEA 常用快捷键
    Xshell 配色方案
    冒泡排序
    递归
    安卓服务Service详解
  • 原文地址:https://www.cnblogs.com/nuccch/p/7687388.html
Copyright © 2011-2022 走看看