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

     

  • 相关阅读:
    php intval()函数
    MVC开发模式
    Session详解
    JSP入门
    Response中文乱码问题
    cookie入门
    idea实现更改servlet模板
    使用new和newInstance()创建类的区别
    Servlet 3.0 新特性详解
    web Servlet 3.0 新特性之web模块化编程,web-fragment.xml编写及打jar包
  • 原文地址:https://www.cnblogs.com/gavincoder/p/13847278.html
Copyright © 2011-2022 走看看