Guest User

Untitled

a guest
Sep 26th, 2011
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. package hu.xxx.services;
  2.  
  3. import org.springframework.jdbc.datasource.SingleConnectionDataSource;
  4.  
  5.  
  6. public class CustomDelegatingDataSourceImpl extends SingleConnectionDataSource {
  7.  
  8.     private String url;
  9.  
  10.  
  11.     private SingleConnectionDataSource targetDataSource;
  12.  
  13.         public SingleConnectionDataSource getTargetDataSource() {
  14.             String password=targetDataSource.getPassword();
  15.             String username=targetDataSource.getUsername();
  16.             String newurl="jdbc:postgresql://192.168.1.9:5432/db1";
  17.             targetDataSource.destroy();
  18.             SingleConnectionDataSource ds=new SingleConnectionDataSource(newurl, username, password, true);
  19.             targetDataSource=ds;
  20.             return targetDataSource;
  21.         }
  22.  
  23.     public void setTargetDataSource(SingleConnectionDataSource targetDataSource) {
  24.         this.targetDataSource = targetDataSource;
  25.     }
  26.  
  27.     @Override
  28.     public String getUrl() {
  29.         return url;
  30.     }
  31.  
  32.     @Override
  33.     public void setUrl(String url) {
  34.         this.url = url;
  35.     }
  36.    
  37.  
  38.  
  39.  
  40. }
  41.  
  42.  
Advertisement
Add Comment
Please, Sign In to add comment