Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hu.xxx.services;
- import org.springframework.jdbc.datasource.SingleConnectionDataSource;
- public class CustomDelegatingDataSourceImpl extends SingleConnectionDataSource {
- private String url;
- private SingleConnectionDataSource targetDataSource;
- public SingleConnectionDataSource getTargetDataSource() {
- String password=targetDataSource.getPassword();
- String username=targetDataSource.getUsername();
- String newurl="jdbc:postgresql://192.168.1.9:5432/db1";
- targetDataSource.destroy();
- SingleConnectionDataSource ds=new SingleConnectionDataSource(newurl, username, password, true);
- targetDataSource=ds;
- return targetDataSource;
- }
- public void setTargetDataSource(SingleConnectionDataSource targetDataSource) {
- this.targetDataSource = targetDataSource;
- }
- @Override
- public String getUrl() {
- return url;
- }
- @Override
- public void setUrl(String url) {
- this.url = url;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment