org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection;

今天在自建一個maven web項目,在進行測試的時候,報錯,詳細信息如下:

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; 
nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory 
(Access denied for user 'root'@'localhost' (using password: YES))
### The error may exist in file [E:\work_pratise\happyrunning\happyrunning\target\classes\com\zxc\happy\mapping\UserMapper.xml]
### The error may involve com.zxc.happy.dao.UserMapper.selectByPrimaryKey
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.
SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))

網上遇到此問題的好多帖子,更多的是表示配置出問題,參考鏈接如下:

http://blog.csdn.net/liwuyang2013/article/details/25986597

http://blog.csdn.net/cool_easy/article/details/42913811

檢查jdbc.properties的配置,路徑以及用戶密碼都沒有問題,驅動類jar包也有,後來仔細檢查,發現在配置文件:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/running_man?useUnicode=true&characterEncoding=utf8
jdbc.username=root
jdbc.password=root 
jdbc.password=root後面有空格,這樣就會報上述錯誤,而且在這四條配置中,若後面有空格,都會報上述錯誤

發佈了70 篇原創文章 · 獲贊 222 · 訪問量 70萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章