1 19 20 21 package org.apache.cayenne.conn; 22 23 import java.io.PrintWriter ; 24 import java.sql.SQLException ; 25 26 import javax.sql.ConnectionPoolDataSource ; 27 import javax.sql.DataSource ; 28 import javax.sql.PooledConnection ; 29 30 40 public class PoolDataSource implements ConnectionPoolDataSource { 41 private DataSource nonPooledDatasource; 42 43 44 public PoolDataSource(DataSource nonPooledDatasource) { 45 this.nonPooledDatasource = nonPooledDatasource; 46 } 47 48 public PoolDataSource(String jdbcDriver, String connectionUrl) throws SQLException { 49 nonPooledDatasource = new DriverDataSource(jdbcDriver, connectionUrl); 50 } 51 52 public int getLoginTimeout() throws SQLException { 53 return nonPooledDatasource.getLoginTimeout(); 54 } 55 56 public void setLoginTimeout(int seconds) throws SQLException { 57 nonPooledDatasource.setLoginTimeout(seconds); 58 } 59 60 public PrintWriter getLogWriter() throws SQLException { 61 return nonPooledDatasource.getLogWriter(); 62 } 63 64 public void setLogWriter(PrintWriter out) throws SQLException { 65 nonPooledDatasource.setLogWriter(out); 66 } 67 68 public PooledConnection getPooledConnection() throws SQLException { 69 return new PooledConnectionImpl(nonPooledDatasource, null, null); 70 } 71 72 public PooledConnection getPooledConnection(String user, String password) throws SQLException { 73 return new PooledConnectionImpl(nonPooledDatasource, user, password); 74 } 75 } 76 | Popular Tags |