+1!!! that's what I would have done at the first attempt of pool2 :) http://people.apache.org/~simonetripodi/ http://www.99soft.org/
On Wed, May 11, 2011 at 4:55 AM, Gary Gregory <garydgreg...@gmail.com> wrote: > On May 10, 2011, at 20:24, Phil Steitz <phil.ste...@gmail.com> wrote: > >> Please raise issues and/or update changes.xml to keep track of these >> changes. >> >> I guess in this case, we might want to doc the fact that we are just >> tracking what dbcp thinks the state of the connection is. If access >> to the underlying connection is allowed and it gets modified, all >> bets are off. >> >> One more little nit - can we agree to stop adding / get rid of the >> _'s in front of variable names? > > +1 > Gary > >> >> Phil >> >> On 5/10/11 4:27 PM, ma...@apache.org wrote: >>> Author: markt >>> Date: Tue May 10 23:27:13 2011 >>> New Revision: 1101678 >>> >>> URL: http://svn.apache.org/viewvc?rev=1101678&view=rev >>> Log: >>> Cache current values of autoCommit and readOnly so DB queries are not >>> required for every call to the getter >>> >>> Modified: >>> >>> commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/DelegatingConnection.java >>> >>> Modified: >>> commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/DelegatingConnection.java >>> URL: >>> http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/DelegatingConnection.java?rev=1101678&r1=1101677&r2=1101678&view=diff >>> ============================================================================== >>> --- >>> commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/DelegatingConnection.java >>> (original) >>> +++ >>> commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/DelegatingConnection.java >>> Tue May 10 23:27:13 2011 >>> @@ -75,6 +75,10 @@ public class DelegatingConnection extend >>> >>> protected boolean _closed = false; >>> >>> + >>> + private Boolean _autoCommitCached = null; >>> + private Boolean _readOnlyCached = null; >>> + >>> /** >>> * Create a wrapper for the Connection which traces this >>> * Connection in the AbandonedObjectPool. >>> @@ -344,9 +348,20 @@ public class DelegatingConnection extend >>> { checkOpen(); try { _conn.commit(); } catch (SQLException e) { >>> handleException(e); } } >>> >>> @Override >>> - public boolean getAutoCommit() throws SQLException >>> - { checkOpen(); try { return _conn.getAutoCommit(); } catch >>> (SQLException e) { handleException(e); return false; } >>> + public boolean getAutoCommit() throws SQLException { >>> + checkOpen(); >>> + if (_autoCommitCached != null) { >>> + return _autoCommitCached.booleanValue(); >>> + } >>> + try { >>> + _autoCommitCached = Boolean.valueOf(_conn.getAutoCommit()); >>> + return _autoCommitCached.booleanValue(); >>> + } catch (SQLException e) { >>> + handleException(e); >>> + return false; >>> + } >>> } >>> + >>> @Override >>> public String getCatalog() throws SQLException >>> { checkOpen(); try { return _conn.getCatalog(); } catch (SQLException >>> e) { handleException(e); return null; } } >>> @@ -375,9 +390,20 @@ public class DelegatingConnection extend >>> { checkOpen(); try { return _conn.getWarnings(); } catch (SQLException >>> e) { handleException(e); return null; } } >>> >>> @Override >>> - public boolean isReadOnly() throws SQLException >>> - { checkOpen(); try { return _conn.isReadOnly(); } catch (SQLException >>> e) { handleException(e); return false; } } >>> - >>> + public boolean isReadOnly() throws SQLException { >>> + checkOpen(); >>> + if (_readOnlyCached != null) { >>> + return _readOnlyCached.booleanValue(); >>> + } >>> + try { >>> + _readOnlyCached = Boolean.valueOf(_conn.isReadOnly()); >>> + return _readOnlyCached.booleanValue(); >>> + } catch (SQLException e) { >>> + handleException(e); >>> + return false; >>> + } >>> + } >>> + >>> @Override >>> public String nativeSQL(String sql) throws SQLException >>> { checkOpen(); try { return _conn.nativeSQL(sql); } catch (SQLException >>> e) { handleException(e); return null; } } >>> @@ -387,16 +413,32 @@ public class DelegatingConnection extend >>> { checkOpen(); try { _conn.rollback(); } catch (SQLException e) { >>> handleException(e); } } >>> >>> @Override >>> - public void setAutoCommit(boolean autoCommit) throws SQLException >>> - { checkOpen(); try { _conn.setAutoCommit(autoCommit); } catch >>> (SQLException e) { handleException(e); } } >>> + public void setAutoCommit(boolean autoCommit) throws SQLException { >>> + checkOpen(); >>> + try { >>> + _conn.setAutoCommit(autoCommit); >>> + _autoCommitCached = Boolean.valueOf(autoCommit); >>> + } catch (SQLException e) { >>> + _autoCommitCached = null; >>> + handleException(e); >>> + } >>> + } >>> >>> @Override >>> public void setCatalog(String catalog) throws SQLException >>> { checkOpen(); try { _conn.setCatalog(catalog); } catch (SQLException >>> e) { handleException(e); } } >>> >>> @Override >>> - public void setReadOnly(boolean readOnly) throws SQLException >>> - { checkOpen(); try { _conn.setReadOnly(readOnly); } catch >>> (SQLException e) { handleException(e); } } >>> + public void setReadOnly(boolean readOnly) throws SQLException { >>> + checkOpen(); >>> + try { >>> + _conn.setReadOnly(readOnly); >>> + _readOnlyCached = Boolean.valueOf(readOnly); >>> + } catch (SQLException e) { >>> + _readOnlyCached = null; >>> + handleException(e); >>> + } >>> + } >>> >>> @Override >>> public void setTransactionIsolation(int level) throws SQLException >>> >>> >>> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org >> For additional commands, e-mail: dev-h...@commons.apache.org >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org