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.
    
  • 相关阅读:
    docker compose示例
    mysql表分区案例
    mysql表分区实战
    mysql分表
    MongoDB基础教程系列--目录结构
    如何优化Mysql千万级快速分页,limit优化快速分页,MySQL处理千万级数据查询的优化方案
    网站性能压力测试工具--apache ab使用详解
    tomcat8 JVM 优化
    tomcat8 性能优化
    redis.properties
  • 原文地址:https://www.cnblogs.com/nuccch/p/7687388.html
Copyright © 2011-2022 走看看