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

news/2024/5/19 0:49:31 标签: jdbc, mysql

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


http://www.niftyadmin.cn/n/1735690.html

相关文章

maven项目引入js或css

在用maven架构引入EasyUI时,一直没有出现效果,经分析:在加载spring容器时,js和css文件被拦截,因为web.xml中DispatcherServlet拦截“/”,拦截了所有请求,包括对*.js,*.css的访问。 访问时&…

解决java.lang.IllegalArgumentException: No converter found for return

一、背景 最近闲来无事&#xff0c;想自己搭建一套SpringSpringMVCMybatisMysql的环境&#xff08;搭建步骤会在以后博客中给出&#xff09;&#xff0c;结果运行程序时&#xff0c;适用ResponseBody注解进行返回List<对象>的json数据时出现了&#xff1a;nested excepti…

tar.xz文件如何解压

XZ压缩最新压缩率之王 xz这个压缩可能很多都很陌生&#xff0c;不过您可知道xz是绝大数Linux默认就带的一个压缩工具。 之前xz使用一直很少&#xff0c;所以几乎没有什么提起。 我是在下载phpmyadmin的时候看到这种压缩格式的&#xff0c;phpmyadmin压缩包xz格式的居然比7z还要…

ElasticSearch-5.0安装head插件

环境 Windows10企业版X64JDK-1.8ElasticSearch-5.0.0node-v4.5.0-x64.msigit客户端 步骤 安装node到D盘。如D:\nodejs。 把NODE_HOME设置到环境变量里(安装包也可以自动加入PATH环境变量)。测试一下node是否生效&#xff1a; 安装grunt grunt是一个很方便的构建工具&#xff0…

Java环境变量配置解决版本不一致问题详解

晚上琢磨ant的使用&#xff0c;需要用java javac编译文件&#xff0c;出现了如上问题。网上找了篇文章&#xff0c;再结合自己的情况改动了下&#xff0c;留着备份记录。 1.进行win8下Java环境变量配置&#xff0c;在"系统变量"下进行如下配置&#xff1a; (1)新建-&…

Java环境变量配置解决版本不一致问题

windows本地装有jdk1.7和1.8两个版本&#xff0c;在修改JAVA_HOME的路径为1.8的安装路径后&#xff0c;cmd命令查看java版本&#xff0c;显示为所需版本1.8&#xff0c;当我需要用jdk1.7版本时&#xff0c;修改路径为1.7的&#xff1a; cmd命令查看&#xff0c;编译版本为1.7&a…

List存放map值

错误代码&#xff1a; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;public class Test {public static void main(String[] args) {List<User> userList new ArrayList<User>();User user1 new User();…

java中String字符串转化成listInteger格式

最近开发中遇到问题&#xff0c;同事在传给我ids时拼接为String字符串格式&#xff0c;转化成List&#xff0c;网上的转化大致为&#xff1a; String[] strs {"1","3","12","33"}; List<String> sList Arrays.asList(strs); 而…