首页 » MySQL » org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Co

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Co

原文 http://blog.csdn.net/zouxucong/article/details/74931988

2017-07-10 19:20:08阅读(618)

今天在自建一个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后面有空格,这样就会报上述错误,而且在这四条配置中,若后面有空格,都会报上述错误

最新发布

CentOS专题

关于本站

5ibc.net旗下博客站精品博文小部分原创、大部分从互联网收集整理。尊重作者版权、传播精品博文,让更多编程爱好者知晓!

小提示

按 Ctrl+D 键,
把本文加入收藏夹