登录
首页 >  数据库 >  MySQL

Failed to obtain JDBC Connection; nested exception

来源:SegmentFault

时间:2023-01-18 10:46:18 379浏览 收藏

哈喽!今天心血来潮给大家带来了《Failed to obtain JDBC Connection; nested exception》,想必大家应该对数据库都不陌生吧,那么阅读本文就都不会很困难,以下内容主要涉及到MySQL、springboot、mysql-connector,若是你正在学习数据库,千万别错过这篇文章~希望能帮助到你!


author: Nathannie
date: 2022-03-26-23:29


问题背景

spingboot整合mybatis过程中启动spingboot报错。

报错信息

报错内容:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user '***'@'localhost' (using password: YES)
### The error may exist in com/itheima/springbootmybatis/mapper/UserMapper.java (best guess)
### The error may involve com.itheima.springbootmybatis.mapper.UserMapper.findAll
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user '***'@'localhost' (using password: YES)

报错定位:

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.

mysql版本问题

8.0以后的版本使用com.mysql.cj.jdbc.Driver驱动,添加了
spring:
  datasource:
    url: jdbc:mysql:///springboot?serverTimezone=GMT
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver

相关参考

终于介绍完啦!小伙伴们,这篇关于《Failed to obtain JDBC Connection; nested exception》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布数据库相关知识,快来关注吧!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表