Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我在配合4.3.11版本的hibernate版本的时候会遇到用户名不匹配的问题。 #967

Open
Misakic opened this issue Sep 30, 2015 · 1 comment

Comments

@Misakic
Copy link

Misakic commented Sep 30, 2015

我在项目中使用的是spring-data-jpa+hibernate+spring的方式设计的数据访问接口
Caused by: java.lang.UnsupportedOperationException: Not supported by DruidDataSource
....
然后我追踪源码发现在DruidDataSource.java这个类中在
@OverRide
public Connection getConnection(String username, String password) throws SQLException {
if (!StringUtils.equals(username, this.username)) {
throw new UnsupportedOperationException("Not supported by DruidDataSource");
}

   if (!StringUtils.equals(password, this.password)) {  
       throw new UnsupportedOperationException("Not supported by DruidDataSource");  
   }  

   return getConnection();  

}
这个地方检测用户名密码的时候不匹配,this.username就是我在druid连接池中配置的用户名,但是getConnection()方法中传入的username名称为sa,我目前初步判断是我没有在hibernateProperties属性中配置数据库的账号和密码,然后hibernate默认使用sa作为数据库的账户,但是我已经在druid中配置了数据库的账号、密码。
目前我的解决办法有两个:
1.在hibernateProperties中再配一次账号密码(我觉得这个步骤有些多余)
${jdbc.username}
${jdbc.password}
2.使用低版本的hibernate,我在使用4.1版本的hibernate就不会有这个问题。
详细的说明我在博客中有介绍:http://blog.csdn.net/misakic52/article/details/47659193

@kervin521
Copy link

spring_hibernate

本人使用spring+hibernate配置完全没有问题,配置版本:
1.spring4.2.1+hibernate4.3.11
2.Spring 3.2.13+hibernate4.2.20
以上两种组合本人均试过是没有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants