001package org.javasimon.jdbcx4; 002 003import java.sql.Connection; 004import java.sql.SQLException; 005import javax.sql.ConnectionEventListener; 006import javax.sql.PooledConnection; 007import javax.sql.StatementEventListener; 008 009import org.javasimon.jdbc4.SimonConnection; 010 011/** 012 * Simon implementation of <code>PooledConnection</code>, needed for 013 * Simon ConnectionPollDataSource implementation. 014 * <p/> 015 * All method invokes its real implementation. 016 * <p/> 017 * See the {@link org.javasimon.jdbcx4 package description} for more 018 * information. 019 * 020 * @author Radovan Sninsky 021 * @author <a href="mailto:virgo47@gmail.com">Richard "Virgo" Richter</a> 022 * @since 2.4 023 */ 024public class SimonPooledConnection implements PooledConnection { 025 private final PooledConnection pooledConn; 026 private final String prefix; 027 028 /** 029 * Class constructor. 030 * 031 * @param connection real pooled connection 032 * @param prefix Simon prefix 033 */ 034 public SimonPooledConnection(PooledConnection connection, String prefix) { 035 this.pooledConn = connection; 036 this.prefix = prefix; 037 } 038 039 @Override 040 public final Connection getConnection() throws SQLException { 041 return new SimonConnection(pooledConn.getConnection(), prefix); 042 } 043 044 @Override 045 public final void close() throws SQLException { 046 pooledConn.close(); 047 } 048 049 @Override 050 public final void addConnectionEventListener(ConnectionEventListener listener) { 051 pooledConn.addConnectionEventListener(listener); 052 } 053 054 @Override 055 public final void removeConnectionEventListener(ConnectionEventListener listener) { 056 pooledConn.removeConnectionEventListener(listener); 057 } 058 059 @Override 060 public void addStatementEventListener(StatementEventListener listener) { 061 pooledConn.addStatementEventListener(listener); 062 } 063 064 @Override 065 public void removeStatementEventListener(StatementEventListener listener) { 066 pooledConn.removeStatementEventListener(listener); 067 } 068}