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

     

  • 相关阅读:
    选择HttpHandler还是HttpModule?
    细说 ASP.NET Cache 及其高级用法
    写自己的ASP.NET MVC框架(下)
    写自己的ASP.NET MVC框架(上)
    细说Cookie
    用Asp.net写自己的服务框架
    我心目中的Asp.net核心对象
    HttpModule与HttpHandler详解
    对协变和逆变的简单理解
    .net项目技术选型总结
  • 原文地址:https://www.cnblogs.com/gavincoder/p/13847278.html
Copyright © 2011-2022 走看看