public Connection unwrap(Connection conn) { if (!canUnwrap(conn)) throw new IllegalArgumentException( "This unwrapper can only handle instances of " + DelegatingConnection.class); Connection unwrapped = ((DelegatingConnection) conn).getInnermostDelegate(); if (unwrapped == null) throw new RuntimeException( "Could not unwrap connection. Is the DBCP pool configured " + "to allow access to underlying connections?"); return unwrapped; }
public Connection getConnection() throws SQLException { return new org.apache.commons.dbcp.DelegatingConnection( java.sql.DriverManager.getConnection( jdbcConnectString, jdbcProperties)); }
static void createFunctions(Connection cx) throws SQLException { while (cx instanceof DelegatingConnection) { cx = ((DelegatingConnection) cx).getDelegate();
protected void activate() { _closed = false; setLastUsed(); if(_conn instanceof DelegatingConnection) { ((DelegatingConnection)_conn).activate(); } }
public Properties getClientInfo() throws SQLException { checkOpen(); try { return _conn.getClientInfo(); } catch (SQLException e) { handleException(e); return null; } }
public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } // Use superclass accessor to skip access test Connection delegate = super.getInnermostDelegate(); if (delegate == null) { return false; } if (obj instanceof DelegatingConnection) { DelegatingConnection c = (DelegatingConnection) obj; return c.innermostDelegateEquals(delegate); } else { return delegate.equals(obj); } }
protected void passivate() throws SQLException { try { // The JDBC spec requires that a Connection close any open // Statement's when it is closed. List statements = getTrace(); if( statements != null) { Statement[] set = new Statement[statements.size()]; statements.toArray(set); for (int i = 0; i < set.length; i++) { set[i].close(); } clearTrace(); } setLastUsed(0); if(_conn instanceof DelegatingConnection) { ((DelegatingConnection)_conn).passivate(); } } finally { _closed = true; } }
public void setClientInfo(String name, String value) throws SQLClientInfoException { try { checkOpen(); _conn.setClientInfo(name, value); } catch (SQLClientInfoException e) { throw e; } catch (SQLException e) { throw new SQLClientInfoException("Connection is closed.", EMPTY_FAILED_PROPERTIES, e); } }
/** * Closes the underlying connection, and close * any Statements that were not explicitly closed. */ public void close() throws SQLException { passivate(); _conn.close(); }
public void activateObject(Object obj) throws Exception { if(obj instanceof DelegatingConnection) { ((DelegatingConnection)obj).activate(); } if(obj instanceof Connection) { Connection conn = (Connection)obj; if (conn.getAutoCommit() != _defaultAutoCommit) { conn.setAutoCommit(_defaultAutoCommit); } if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) && (conn.getTransactionIsolation() != _defaultTransactionIsolation)) { conn.setTransactionIsolation(_defaultTransactionIsolation); } if ((_defaultReadOnly != null) && (conn.isReadOnly() != _defaultReadOnly.booleanValue())) { conn.setReadOnly(_defaultReadOnly.booleanValue()); } if ((_defaultCatalog != null) && (!_defaultCatalog.equals(conn.getCatalog()))) { conn.setCatalog(_defaultCatalog); } } }
protected void activate() throws SQLException{ _closed = false; if(_conn != null) { _conn.addTrace(this); } super.activate(); }
/** * Actually close my underlying {@link Connection}. */ public void reallyClose() throws SQLException { super.close(); } }
public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } // Use superclass accessor to skip access test Connection conn = super.getInnermostDelegate(); if (conn == null) { return false; } if (obj instanceof DelegatingConnection) { DelegatingConnection c = (DelegatingConnection) obj; return c.innermostDelegateEquals(conn); } else { return conn.equals(obj); } }
public NClob createNClob() throws SQLException { checkOpen(); try { return _conn.createNClob(); } catch (SQLException e) { handleException(e); return null; } }
protected void passivate() throws SQLException { try { // The JDBC spec requires that a Connection close any open // Statement's when it is closed. // DBCP-288. Not all the traced objects will be statements List traces = getTrace(); if(traces != null) { Iterator traceIter = traces.iterator(); while (traceIter.hasNext()) { Object trace = traceIter.next(); if (trace instanceof Statement) { ((Statement) trace).close(); } else if (trace instanceof ResultSet) { // DBCP-265: Need to close the result sets that are // generated via DatabaseMetaData ((ResultSet) trace).close(); } } clearTrace(); } setLastUsed(0); if(_conn instanceof DelegatingConnection) { ((DelegatingConnection)_conn).passivate(); } } finally { _closed = true; } }
public void setClientInfo(Properties properties) throws SQLClientInfoException { try { checkOpen(); _conn.setClientInfo(properties); } catch (SQLClientInfoException e) { throw e; } catch (SQLException e) { throw new SQLClientInfoException("Connection is closed.", EMPTY_FAILED_PROPERTIES, e); } }
/** * Closes the underlying connection, and close * any Statements that were not explicitly closed. */ public void close() throws SQLException { passivate(); _conn.close(); }
protected void activate() { _closed = false; setLastUsed(); if(_conn instanceof DelegatingConnection) { ((DelegatingConnection)_conn).activate(); } }
public void activateObject(Object obj) throws Exception { if(obj instanceof DelegatingConnection) { ((DelegatingConnection)obj).activate(); } if(obj instanceof Connection) { Connection conn = (Connection)obj; if (conn.getAutoCommit() != _defaultAutoCommit) { conn.setAutoCommit(_defaultAutoCommit); } if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) && (conn.getTransactionIsolation() != _defaultTransactionIsolation)) { conn.setTransactionIsolation(_defaultTransactionIsolation); } if ((_defaultReadOnly != null) && (conn.isReadOnly() != _defaultReadOnly.booleanValue())) { conn.setReadOnly(_defaultReadOnly.booleanValue()); } if ((_defaultCatalog != null) && (!_defaultCatalog.equals(conn.getCatalog()))) { conn.setCatalog(_defaultCatalog); } } }
protected void activate() throws SQLException{ _closed = false; if(_conn != null) { _conn.addTrace(this); } super.activate(); }