一、問題描述
異常信息:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is 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: Connections could not be acquired from the underlying database!
二、原因排查
通過上網(wǎng)查證,主要是可能有三類問題導(dǎo)致這個(gè)錯(cuò)誤
第一類:數(shù)據(jù)庫(kù)的權(quán)限問題
數(shù)據(jù)庫(kù)未啟動(dòng)或無權(quán)訪問
mysql root沒有遠(yuǎn)程訪問的權(quán)限,需要增加權(quán)限
第二類:配置信息錯(cuò)誤(8.0以上版本沒有添加時(shí)區(qū))
驅(qū)動(dòng)配置有誤:driver=com.mysql.cj.jdbc.Driver
數(shù)據(jù)庫(kù)連接地址有誤:url=jdbc:mysql://localhost:3306/test(此處修改為自己的)?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT&nullCatalogMeansCurrent = true
密碼或帳號(hào)有誤
但是如果是賬號(hào)密碼錯(cuò)誤會(huì)顯示以下錯(cuò)誤信息:Access denied for user ‘root’@‘localhost’ (using password: YES))文章來源:http://www.zghlxwxcb.cn/news/detail-839484.html
第三類:MySQL驅(qū)動(dòng)版本問題
在沒有低級(jí)失誤的情況下,大概率是這里導(dǎo)致的文章來源地址http://www.zghlxwxcb.cn/news/detail-839484.html
到了這里,關(guān)于Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed異常的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!