Hi Bob,
thanks for explaining - I know what you mean.
Now I have create a subclass of DelegatingDataSource and inject the targetDataSource with the real datasource config (see above). When I overwrite the getConnection and getConnection(user, password) I get following stacktrace:
Code:
at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:116)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:554)
at org.springframework.jdbc.datasource.DelegatingDataSource.getConnection(DelegatingDataSource.java:68)
at config.DataSourceWrapper.getConnection(DataSourceWrapper.java:16)
at org.springframework.orm.hibernate.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:76)
Here part of config for Hibernate and datasource
Code:
<bean id="dsWrapper" class="config.DataSourceWrapper">
<property name="targetDataSource" ref="localMySqlDataSource"/>
</bean>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dsWrapper"/>
</property>
<property name="hibernateProperties">
<ref local="hibernateProperties"/>
</property>
.....
Here the new class:
Code:
public class DataSourceWrapper extends DelegatingDataSource {
public Connection getConnection() throws SQLException {
return super.getConnection("user", "password");
}
public Connection getConnection(String username, String password) throws SQLException {
return super.getConnection("user", "password");
}
}
Does someone have a hint for me what I'm doing wrong?
___________
Alex