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

     

  • 相关阅读:
    dp(传球)
    最长上升子序列
    FromData获取表单数据
    php解决高并发问题
    php抽象类、接口、traint详解
    mysql、mongodb、redis 数据库之间的区别
    phpstorm2018 安装及破解方法
    phpstudy添加redis扩展
    mysql触发器trigger 实例详解
    mysql查询系列常考问题
  • 原文地址:https://www.cnblogs.com/gavincoder/p/13847278.html
Copyright © 2011-2022 走看看