1 56 57 package org.objectstyle.cayenne.conn; 58 59 import java.io.PrintWriter ; 60 import java.sql.SQLException ; 61 62 import javax.sql.ConnectionPoolDataSource ; 63 import javax.sql.DataSource ; 64 import javax.sql.PooledConnection ; 65 66 76 public class PoolDataSource implements ConnectionPoolDataSource { 77 private DataSource nonPooledDatasource; 78 79 80 public PoolDataSource(DataSource nonPooledDatasource) { 81 this.nonPooledDatasource = nonPooledDatasource; 82 } 83 84 public PoolDataSource(String jdbcDriver, String connectionUrl) throws SQLException { 85 nonPooledDatasource = new DriverDataSource(jdbcDriver, connectionUrl); 86 } 87 88 public int getLoginTimeout() throws SQLException { 89 return nonPooledDatasource.getLoginTimeout(); 90 } 91 92 public void setLoginTimeout(int seconds) throws SQLException { 93 nonPooledDatasource.setLoginTimeout(seconds); 94 } 95 96 public PrintWriter getLogWriter() throws SQLException { 97 return nonPooledDatasource.getLogWriter(); 98 } 99 100 public void setLogWriter(PrintWriter out) throws SQLException { 101 nonPooledDatasource.setLogWriter(out); 102 } 103 104 public PooledConnection getPooledConnection() throws SQLException { 105 return new PooledConnectionImpl(nonPooledDatasource, null, null); 106 } 107 108 public PooledConnection getPooledConnection(String user, String password) throws SQLException { 109 return new PooledConnectionImpl(nonPooledDatasource, user, password); 110 } 111 } 112 | Popular Tags |