/[Apache-SVN]/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/PoolingDriver.java
ViewVC logotype

Diff of /jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/PoolingDriver.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 132180, Mon May 17 18:39:44 2004 UTC revision 153465, Fri Feb 11 22:16:47 2005 UTC
# Line 46  import org.xml.sax.SAXException; Line 46  import org.xml.sax.SAXException;
46   *   *
47   * @author Rodney Waldhoff   * @author Rodney Waldhoff
48   * @author Dirk Verbeeck   * @author Dirk Verbeeck
49   * @version $Revision: 1.12 $ $Date: 2004/05/17 18:39:44 $   * @version $Revision: 1.12 $ $Date$
50   */   */
51  public class PoolingDriver implements Driver {  public class PoolingDriver implements Driver {
52      /** Register an myself with the {@link DriverManager}. */      /** Register an myself with the {@link DriverManager}. */
# Line 174  public class PoolingDriver implements Dr Line 174  public class PoolingDriver implements Dr
174                  try {                  try {
175                      Connection conn = (Connection)(pool.borrowObject());                      Connection conn = (Connection)(pool.borrowObject());
176                      if (conn != null) {                      if (conn != null) {
177                          conn = new PoolGuardConnectionWrapper(conn);                          conn = new PoolGuardConnectionWrapper(pool, conn);
178                      }                      }
179                      return conn;                      return conn;
180                  } catch(SQLException e) {                  } catch(SQLException e) {
# Line 192  public class PoolingDriver implements Dr Line 192  public class PoolingDriver implements Dr
192          }          }
193      }      }
194    
195        public void invalidateConnection(Connection conn) throws SQLException {
196            if (conn instanceof PoolGuardConnectionWrapper) { // normal case
197                PoolGuardConnectionWrapper pgconn = (PoolGuardConnectionWrapper) conn;
198                ObjectPool pool = pgconn.pool;
199                Connection delegate = pgconn.delegate;
200                try {
201                    pool.invalidateObject(delegate);
202                }
203                catch (Exception e) {
204                }
205                pgconn.delegate = null;
206            }
207            else {
208                throw new SQLException("Invalid connection class");
209            }
210        }
211    
212      public int getMajorVersion() {      public int getMajorVersion() {
213          return MAJOR_VERSION;          return MAJOR_VERSION;
214      }      }
# Line 222  public class PoolingDriver implements Dr Line 239  public class PoolingDriver implements Dr
239       */       */
240      private class PoolGuardConnectionWrapper extends DelegatingConnection {      private class PoolGuardConnectionWrapper extends DelegatingConnection {
241    
242            private ObjectPool pool;
243          private Connection delegate;          private Connection delegate;
244    
245          PoolGuardConnectionWrapper(Connection delegate) {          PoolGuardConnectionWrapper(ObjectPool pool, Connection delegate) {
246              super(delegate);              super(delegate);
247                this.pool = pool;
248              this.delegate = delegate;              this.delegate = delegate;
249          }          }
250    

Legend:
Removed from v.132180  
changed lines
  Added in v.153465

apache@apache.org
ViewVC Help
Powered by ViewVC 1.1.2