1 28 29 30 package com.caucho.tools.profiler; 31 32 import javax.sql.ConnectionPoolDataSource ; 33 import javax.sql.PooledConnection ; 34 import java.io.PrintWriter ; 35 import java.sql.SQLException ; 36 37 public final class ConnectionPoolDataSourceWrapper 38 implements ConnectionPoolDataSource 39 { 40 private final ProfilerPoint _profilerPoint; 41 private final ConnectionPoolDataSource _dataSource; 42 43 public ConnectionPoolDataSourceWrapper(ProfilerPoint profilerPoint, 44 ConnectionPoolDataSource dataSource) 45 { 46 _profilerPoint = profilerPoint; 47 _dataSource = dataSource; 48 } 49 50 public PooledConnection getPooledConnection() 51 throws SQLException 52 { 53 return wrap(_dataSource.getPooledConnection()); 54 } 55 56 private PooledConnection wrap(PooledConnection pooledConnection) 57 { 58 return new PooledConnectionWrapper(_profilerPoint, pooledConnection); 59 } 60 61 public PooledConnection getPooledConnection(String user, String password) 62 throws SQLException 63 { 64 return wrap(_dataSource.getPooledConnection(user, password)); 65 } 66 67 public PrintWriter getLogWriter() 68 throws SQLException 69 { 70 return _dataSource.getLogWriter(); 71 } 72 73 public void setLogWriter(PrintWriter out) 74 throws SQLException 75 { 76 _dataSource.setLogWriter(out); 77 } 78 79 public void setLoginTimeout(int seconds) 80 throws SQLException 81 { 82 _dataSource.setLoginTimeout(seconds); 83 } 84 85 public int getLoginTimeout() 86 throws SQLException 87 { 88 return _dataSource.getLoginTimeout(); 89 } 90 91 public String toString() 92 { 93 return "ConnectionPoolDataSourceWrapper[" + _profilerPoint.getName() + "]"; 94 } 95 } 96 | Popular Tags |