zoukankan      html  css  js  c++  java
  • Mysql url参数浅析

    驱动包用的是mysql-connector-java-8.0.11.jar
    新版的驱动类改成了com.mysql.cj.jdbc.Driver

    //北京时间东八区
    serverTimezone=GMT%2B8
    //或者使用上海时间
    serverTimezone=Asia/Shanghai

    如果设置成UTC,连接不会报错,但是时间会不一致,有时差。
    UTC代表的是全球标准时间 ,但是我们使用的时间是北京时区也就是东八区,领先UTC八个小时。

    //北京时间东八区

    jdbc.driverClassName=com.mysql.jdbc.Driver
    jdbc.url=jdbc:mysql://localhost:3306/database?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE&useSSL=true&serverTimezone=UTC
    jdbc.username=root
    jdbc.password=password

    需要注意的是,在xml配置文件中,url中的&符号需要转义成 &

    autoReconnect建议配上,否则可能会因为缓存缘故,读取不到DB最新配置,导致一直无法使用utf8mb4字符集

    allowMultiQueries 设置为true,开启批量执行SQL的开关

    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.
    不建议在没有服务器身份验证的情况下建立SSL连接。根据MySQL 5.5.45+、5.6.26+和5.7.6+的要求,如果不设置显式选项,则必须建立默认的SSL连接。需要通过设置useSSL=false来显式禁用SSL,或者设置useSSL=true并为服务器证书验证提供信任存储。

    大概意思就是MySql在高版本需要指明是否进行SSL连接

    所以加上useSSL即可解决该问题

    希望可以帮助到大家,大家也可关注我的公众号方便在手机上进行查看

  • 相关阅读:
    查看自己的笔记本是否支持64位系统
    关闭445端口
    与postgis相关的一些常用的sql
    postgis 赋予postgresql空间数据库的能力
    ThreadLocal
    获取跨域请求的自定义的response headers
    java Bean的映射工具
    Java多线程学习
    (14)Spring Boot定时任务的使用【从零开始学Spring Boot】
    (13)处理静态资源(自定义资源映射)【从零开始学Spring Boot】
  • 原文地址:https://www.cnblogs.com/caozz/p/10112162.html
Copyright © 2011-2022 走看看