Could not get JDBC Connection
来源:互联网 发布:uitableview优化方案 编辑:程序博客网 时间:2024/05/16 08:05
org.apache.ibatis.exceptions.PersistenceException: ### 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 mapper/CustomerMapper.xml ### The error may involve com.zhexiang.mybatis_springmvc.model.selectCustomerByID ### 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)) at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66) at com.zhexiang.mybatis_springmvc.dao.impl.CustomerDaoImpl.selectCustomerByID(CustomerDaoImpl.java:18) at com.zhexiang.mybatis_springmvc.dao.impl.CustomerDaoImplTest.testSelectCustomerByID(CustomerDaoImplTest.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
jdbc.properties如下:
driver=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=gbk username=root password=rootspring
配置文件:
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource" > <property name="driverClassName" value="${driver}"/> <property name="url" value="${url}" /> <property name="username" value="${username}" /> <property name="password" value="${password}" /> </beans>
当出现上面的Exception,而且spring的配置文件如上面两个文件所示时,无法连接数据库的原因在于
<property name="username" value="${username}" /> 这一行因为此时${username}的值并不是jdbc.properties文件中的username值,而是JVM系统环境变量的username。spring容器在管理PropertySource时,不光读取自己写的properties文件,spring也会把JVM system properties和JVM system env properties都读取到容器中,所以请不要使用和JVM properties相同的key。 0 0
- Could not get JDBC Connection
- Could not get JDBC Connection
- Could not get JDBC Connection
- Could not get JDBC Connection
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection解决办法
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection;
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons
- org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exc
- Oracle数据源:org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection;
- Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nes
- Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransien
- Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection问题排查
- Could not get JDBC Connection; nested exception is org.apache.tomcat.jdbc.pool.PoolExhaustedExceptio
- Could not get JDBC Connection; nested exception is org.apache.tomcat.dbcp.db
- 启动报Cannot get connection for url jdbc xxxx listener could not hand off client co
- 关于SVN的使用
- erlang tcp服务器和客户端的简单实现
- Java基础---hashmap的实现原理
- test
- Cocos2d-x动画,翻开,翻页,淡入淡出动画
- Could not get JDBC Connection
- 浅拷贝和深拷贝的区别
- Mashup
- Web应用过滤器Fileter
- 用JFinal框架自带的main方法运行正常的情况下,用tomcat发布项目出现css样式表引用错误和资源找不到问题。
- 类名.this与类名.class
- Spring的第一个程序
- 重拾linux 驱动 3 ----在驱动中使用映射地址的方式访问硬件
- Android Studio 中编译JDK 版本配置