1,问题现象
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))
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:195)
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:293)
com.knowledge.data.dao.imp.ContentDAOImp.queryContent(ContentDAOImp.java:13)
com.knowledge.data.service.imp.Content
ServiceImp.queryContent(ContentServiceImp.java:20)
com.knowledge.data.action.ContentAction.queryContent(ContentAction.java:39)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
2,问题分析
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close" scope="singleton">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc\:mysql\://localhost\:3306/knowledge" /> <property name="username" value="root" />
<property name="password" value="root" />
</bean>
多了“\”
3,问题解决方法去掉“\”