Skip to main content

Mysql-connector-java驱动版本问题

Mysql-connector-java驱动版本问题 - Hi friends, I hope you are all in good healthzonetechnoupdate, In the article you are reading this time with the title Mysql-connector-java驱动版本问题 , We have prepared this article well for you to read and take information in it. hopefully the contents of the post what we write you can understand. ok, happy reading.

Title : Mysql-connector-java驱动版本问题
link : Mysql-connector-java驱动版本问题

read also


    Mysql-connector-java驱动版本问题

    Mysql-connector-java驱动版本问题

    由于我的数据库版本是5.7.28 ,在使用java连接mysql时经常出现版本问题。

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

    • com.mysql.cj.jdbc.Driver 是 mysql-connector-java 6中的

    不推荐不使用服务器身份验证来建立SSL连接。
    如果未明确设置,MySQL 5.5.45+, 5.6.26+ and 5.7.6+版本默认要求建立SSL连接。
    为了符合当前不使用SSL连接的应用程序,verifyServerCertificate属性设置为'false'。
    如果你不需要使用SSL连接,你需要通过设置useSSL=false来显式禁用SSL连接。
    如果你需要用SSL连接,就要为服务器证书验证提供信任库,并设置useSSL=true。

    SSL – Secure Sockets Layer(安全套接层)

    • 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.
    报错原因: MySQL5用的驱动url是com.mysql.jdbc.Driver,MySQL6以后用的是com.mysql.cj.jdbc.Driver。版本不匹配便会报驱动类已过时的错误。解决方法: 更改配置文件中的驱动类名字就可以消除驱动类过时的警告了。

    mysql5.7.28版本即使改了驱动名为com.mysql.cj.jdbc.Driver也还是会报错,原因在于没有将pom项目对象模型文件中版本改成

    mysql-connector-java8.0以上

    mysql-connector-java与Mysql对应版本

    mysql-connector-java与Mysql对应版本

    • 由于我的是mysql5.7.28 使用connector-java version 5.1的版本,还是会出现上面的报错。因此在mysql5.6以上使用connector-java 8.0以上,

      而且在使用时需要对时区进行设置

      driverClassName=com.mysql.cj.jdbc.Driverurl=jdbc:mysql://localhost:3306/数据库名?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=falseusername=rootpassword=
      • 此处的serverTimezone一定得写serverTimezone=Asia/Shanghai,写成serverTimezone=Shanghai也会报错,貌似是找不到shanghai这个时区,可能是全球的shanghai不止一个,哈哈!

    mysql-connector-java与Java对应版本

    mysql-connector-java与Java对应版本

    鉴于以上,对于初学的小伙伴还是直接用mysql-connector-java 8.0 以上









    原文转载:http://www.shaoqun.com/a/805637.html

    跨境电商:https://www.ikjzd.com/

    mil:https://www.ikjzd.com/w/1285

    法瑞儿:https://www.ikjzd.com/w/412

    reverb:https://www.ikjzd.com/w/1273

    燕文物流:https://www.ikjzd.com/w/2229


    Mysql-connector-java驱动版本问题由于我的数据库版本是5.7.28,在使用java连接mysql时经常出现版本问题。com.mysql.jdbc.Driver是mysql-connector-java5中的,com.mysql.cj.jdbc.Driver是mysql-connector-java6中的不推荐不使用服务器身份验证来建立SSL连接。如果未明确设置,MySQL5.5.
    new old stock:https://www.ikjzd.com/w/2341
    美森:https://www.ikjzd.com/w/1693
    刘小东:https://www.ikjzd.com/w/1853
    女同口述:同性恋人要与我私奔:http://lady.shaoqun.com/a/273688.html
    口述我和美女老师的相爱经历 初尝爱情禁果后不知所措:http://www.30bags.com/a/250307.html
    浪货嗯,这么湿还说不要 那晚闷骚人妻比我还要疯狂:http://www.30bags.com/m/a/254998.html
    速卖通欧盟VAT税改政策答疑:https://www.ikjzd.com/articles/145762
    两性关系:男人容易"误会"的四个潜台词你都说了吗?:http://www.30bags.com/a/393389.html
    两性关系:男人容易"误会"的四个潜台词你都说了吗?:http://lady.shaoqun.com/a/376155.html


    That's the article Mysql-connector-java驱动版本问题

    That's it for the article Mysql-connector-java驱动版本问题 this time, hopefully can be useful for all of you. okay, see you in another article post.

    You are now reading the article Mysql-connector-java驱动版本问题 with link address https://zonetechno-update.blogspot.com/2021/06/mysql-connector-java.html
    Comment Policy: Please write your comments that match the topic of this page post. Comments containing links will not be displayed until they are approved.
    Open Comments
    Close Comment