zoukankan      html  css  js  c++  java
  • Mysql与JDBC版本兼容性问题

    一、报错信息

    mybaits查询报错:

    Tue Oct 20 15:46:34 CST 2020
    There was an unexpected error (type=Internal Server Error, status=500).nested exception is org.apache.ibatis.exceptions.PersistenceException: 
    ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
    Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
    ### The error may exist in file [D:projectmybatis argetclassesmapperTruckInfoMapper.xml]
    ### The error may involve com.example.mybatis.cache.dao.mapper.TruckInfoMapper.getTruckInfo
    ### The error occurred
    while executing a query
    ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException:
    Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.

    二、问题排查

      从报错信息上预测是JDBC连接获取失败导致。因此,首先查询mysql版本和jdbc版本。

    1、查询mysql版本

     Mysql版本为8.0.19。

    2、查询JDBC版本

     JDBC版本为5.1.39。

    3、问题结论

      Mysql与JDBC版本不一致,兼容性问题导致JDBC连接获取失败。

    三、解决方案

    1、升级JDBC版本,5.1.39--->8.0.122、修改数据库驱动,  driver-class-name: com.mysql.cj.jdbc.Driver

     

  • 相关阅读:
    Callable、Future和FutureTask使用说明
    WebSocket原理及与http1.0/1.1 long poll和 ajax轮询的区别【转自知乎】
    jvm内存模型及分配参数
    CyclicBarrier 使用说明
    【LOJ6515】贪玩蓝月
    【LOJ6482】LJJ 爱数数 数论
    【CF1063F】String Journey 哈希
    【CF1063D】Candies for Children 数学
    【XSY2851】蛋糕 数学
    2018百度之星大赛游记
  • 原文地址:https://www.cnblogs.com/gavincoder/p/13847278.html
Copyright © 2011-2022 走看看