org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection 解決辦法
- 檢查pom檔案裡的座標的mysql版本是否匯入正確
<!-- mysql資料庫驅動包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
- 資料庫配置是否出錯
檢查專案的jdbc.properties檔案,如果是mysql 8的話,jdbc.driver應該是com.mysql.cj.jdbc.Driver,別忘了cj。
正確的配置應該是:
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/bank?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=true
jdbc.username=root
jdbc.password=root
如果是mysql 5的話,正確的配置應該是:
driverClassName=com.MySQL.jdbc.Driver
url=jdbc:mysql://localhost:3306/bank
username=root
password=root
注意:專案的jdbc.properties檔案的配置資訊與pom檔案裡匯入的mysql座標的版本應該匹配,否則就會報此異常
相關文章
- Laravel 安裝 sail時ubuntu軟體源很慢或者connection failed 解決辦法LaravelAIUbuntu
- 解決 Android studio Connect to 127.0.0.1:[/127.0.0.1] failed: Connection refusedAndroid127.0.0.1AI
- IDEA提示failed to load JVM DLL的解決辦法IdeaAIJVM
- FileZilla:425 Can't open data connection for transfer of解決辦法
- RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED解決辦法ErrorDNNAI
- vscode中Git: host key verification failed的解決辦法VSCodeGitAI
- Cargo invocation has failed: Error: exit code: 101.解決辦法CargoAIError
- Navicat tnt版本提示“failed to save password error code”的解決辦法AIError
- SVN報錯“Failed to run the WC DB work queue associated with”解決辦法AI
- docker dm_task_run failed 啟動失敗解決辦法DockerAI
- command 'gcc' failed with exit status 1錯誤問題的解決辦法GCAI
- PyCharm啟動報錯:Failed to create JVM.解決辦法之一PyCharmAIJVM
- ascp: Failed to open TCP connection for SSH, exiting. Session Stop (Error: Failed to open TCP connection for SSH)AITCPSessionError
- OGG Director報錯 Connection FAILEDAI
- github慢解決辦法Github
- Namespoace Terminating 解決辦法
- 檔案無法粉碎解決辦法
- SQLServer映象報錯Connection handshake failedSQLServerAI
- Error: Connection activation failed: Device not managed by NetworkManagerErrorAIdev
- 公寓噪音的解決辦法
- height:100%失效解決辦法
- 解決:Failed to load ApplicationContextAIAPPContext
- 記vscode無法啟動解決辦法VSCode
- 在IDEA中使用JDBC獲取資料庫連線時的報錯及解決辦法IdeaJDBC資料庫
- Failed to get D-Bus connection: Operation not permittedAIMIT
- Could not obtain transaction-synchronized Session for current thread原因及解決方案AIsynchronizedSessionthread
- 解決Mac終端下載報錯 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refusedMacAIGithub
- -bash: XXX: command not found解決辦法
- cnpm link 報錯解決辦法NPM
- mysql事件關閉解決辦法MySql事件
- IDEA 找不到包解決辦法Idea
- 資料傾斜解決辦法
- SpringBoot 迴圈引用解決辦法Spring Boot
- VScode 更新失敗解決辦法VSCode
- npm install 失敗解決辦法NPM
- github訪問受限解決辦法Github
- 跨域問題解決辦法跨域
- SqlServer鎖表解鎖解決辦法SQLServer