You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
我在项目中使用的是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();
我在项目中使用的是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");
}
}
这个地方检测用户名密码的时候不匹配,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
The text was updated successfully, but these errors were encountered: