001package org.javasimon.jdbcx4; 002 003import java.sql.SQLException; 004import java.sql.SQLFeatureNotSupportedException; 005import java.util.logging.Logger; 006import javax.sql.ConnectionPoolDataSource; 007import javax.sql.PooledConnection; 008 009/** 010 * Wrapper class for real ConnectionPoolDataSource implementation, produces pooled 011 * {@link javax.sql.PooledConnection} object. 012 * <p/> 013 * See the {@link SimonDataSource} for more information. 014 * 015 * @author Radovan Sninsky 016 * @author <a href="mailto:virgo47@gmail.com">Richard "Virgo" Richter</a> 017 * @since 2.4 018 */ 019public final class SimonConnectionPoolDataSource extends AbstractSimonDataSource implements ConnectionPoolDataSource { 020 private ConnectionPoolDataSource ds; 021 022 private ConnectionPoolDataSource datasource() throws SQLException { 023 if (ds == null) { 024 ds = createDataSource(ConnectionPoolDataSource.class); 025 } 026 return ds; 027 } 028 029 @Override 030 public PooledConnection getPooledConnection() throws SQLException { 031 return new SimonPooledConnection(datasource().getPooledConnection(), getPrefix()); 032 } 033 034 @Override 035 public PooledConnection getPooledConnection(String user, String password) throws SQLException { 036 return new SimonPooledConnection(datasource().getPooledConnection(user, password), getPrefix()); 037 } 038 039 @Override 040 protected String doGetRealDataSourceClassName() { 041 return configuration.getRealConnectionPoolDataSourceName(); 042 } 043 044 @Override 045 public Logger getParentLogger() throws SQLFeatureNotSupportedException { 046 return ds.getParentLogger(); 047 } 048}