您的位置:首页 > 运维架构

org.hibernate.exception.GenericJDBCException: Could not open connection

2014-03-01 23:14 645 查看
使用spring配置文件连接数据库时出现:Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory

(Access denied for user 'wang'@'localhost' (using password: YES)) //wang是我的电脑用户名

出错的配置文件如下:

applicationContext.xml文件中:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

<property name="driverClassName" value="${driverclass}"></property>

<property name="url" value="${url}"></property>

<property name="username" value="${username}"></property>

<property name="password" value="${password}"></property>

</bean>

jdbc.properties文件中:

driverclass=com.mysql.jdbc.Driver

url=jdbc:mysql://localhost:3306/oa

username=root

password=tiger

applicationContext配置参数中username使用${username}貌似得到的是系统用户名,而不是properties文件中的值

在properties文件中不要使用username = ***,可以使用user

改为user后错误就没有了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐