| Method from org.apache.commons.dbcp.DelegatingConnection Detail: |
protected void activate() {
_closed = false;
setLastUsed();
if(_conn instanceof DelegatingConnection) {
((DelegatingConnection)_conn).activate();
}
}
|
protected void checkOpen() throws SQLException {
if(_closed) {
throw new SQLException
("Connection " + _conn + " is closed.");
}
}
|
public void clearWarnings() throws SQLException {
checkOpen(); try { _conn.clearWarnings(); } catch (SQLException e) { handleException(e); }
}
|
public void close() throws SQLException {
passivate();
_conn.close();
}
Closes the underlying connection, and close
any Statements that were not explicitly closed. |
public void commit() throws SQLException {
checkOpen(); try { _conn.commit(); } catch (SQLException e) { handleException(e); }
}
|
public Statement createStatement() throws SQLException {
checkOpen();
try {
return new DelegatingStatement(this, _conn.createStatement());
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public Statement createStatement(int resultSetType,
int resultSetConcurrency) throws SQLException {
checkOpen();
try {
return new DelegatingStatement
(this, _conn.createStatement(resultSetType,resultSetConcurrency));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
checkOpen();
try {
return new DelegatingStatement(this, _conn.createStatement(
resultSetType, resultSetConcurrency, resultSetHoldability));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
Connection delegate = getInnermostDelegate();
if (delegate == null) {
return false;
}
if (obj instanceof DelegatingConnection) {
DelegatingConnection c = (DelegatingConnection) obj;
return c.innermostDelegateEquals(delegate);
}
else {
return delegate.equals(obj);
}
}
|
public boolean getAutoCommit() throws SQLException {
checkOpen(); try { return _conn.getAutoCommit(); } catch (SQLException e) { handleException(e); return false; }
}
|
public String getCatalog() throws SQLException {
checkOpen(); try { return _conn.getCatalog(); } catch (SQLException e) { handleException(e); return null; }
}
|
public Connection getDelegate() {
return _conn;
}
|
public int getHoldability() throws SQLException {
checkOpen(); try { return _conn.getHoldability(); } catch (SQLException e) { handleException(e); return 0; }
}
|
public Connection getInnermostDelegate() {
Connection c = _conn;
while(c != null && c instanceof DelegatingConnection) {
c = ((DelegatingConnection)c).getDelegate();
if(this == c) {
return null;
}
}
return c;
}
If my underlying Connection is not a
DelegatingConnection, returns it,
otherwise recursively invokes this method on
my delegate.
Hence this method will return the first
delegate that is not a DelegatingConnection,
or null when no non-DelegatingConnection
delegate can be found by transversing this chain.
This method is useful when you may have nested
DelegatingConnections, and you want to make
sure to obtain a "genuine" Connection . |
public DatabaseMetaData getMetaData() throws SQLException {
checkOpen(); try { return _conn.getMetaData(); } catch (SQLException e) { handleException(e); return null; }
}
|
public int getTransactionIsolation() throws SQLException {
checkOpen(); try { return _conn.getTransactionIsolation(); } catch (SQLException e) { handleException(e); return -1; }
}
|
public Map getTypeMap() throws SQLException {
checkOpen(); try { return _conn.getTypeMap(); } catch (SQLException e) { handleException(e); return null; }
}
|
public SQLWarning getWarnings() throws SQLException {
checkOpen(); try { return _conn.getWarnings(); } catch (SQLException e) { handleException(e); return null; }
}
|
protected void handleException(SQLException e) throws SQLException {
throw e;
}
|
public int hashCode() {
Object obj = getInnermostDelegate();
if (obj == null) {
return 0;
}
return obj.hashCode();
}
|
public boolean innermostDelegateEquals(Connection c) {
Connection innerCon = getInnermostDelegate();
if (innerCon == null) {
return c == null;
} else {
return innerCon.equals(c);
}
}
Compares innermost delegate to the given connection. |
public boolean isClosed() throws SQLException {
if(_closed || _conn.isClosed()) {
return true;
}
return false;
}
|
public boolean isReadOnly() throws SQLException {
checkOpen(); try { return _conn.isReadOnly(); } catch (SQLException e) { handleException(e); return false; }
}
|
public String nativeSQL(String sql) throws SQLException {
checkOpen(); try { return _conn.nativeSQL(sql); } 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.
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 CallableStatement prepareCall(String sql) throws SQLException {
checkOpen();
try {
return new DelegatingCallableStatement(this, _conn.prepareCall(sql));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency) throws SQLException {
checkOpen();
try {
return new DelegatingCallableStatement
(this, _conn.prepareCall(sql, resultSetType,resultSetConcurrency));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public CallableStatement prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
checkOpen();
try {
return new DelegatingCallableStatement(this, _conn.prepareCall(
sql, resultSetType, resultSetConcurrency, resultSetHoldability));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement
(this, _conn.prepareStatement(sql));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql,
int autoGeneratedKeys) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement(this, _conn.prepareStatement(
sql, autoGeneratedKeys));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql,
int[] columnIndexes) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement(this, _conn.prepareStatement(
sql, columnIndexes));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql,
String[] columnNames) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement(this, _conn.prepareStatement(
sql, columnNames));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement
(this, _conn.prepareStatement
(sql,resultSetType,resultSetConcurrency));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public PreparedStatement prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException {
checkOpen();
try {
return new DelegatingPreparedStatement(this, _conn.prepareStatement(
sql, resultSetType, resultSetConcurrency, resultSetHoldability));
}
catch (SQLException e) {
handleException(e);
return null;
}
}
|
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
checkOpen(); try { _conn.releaseSavepoint(savepoint); } catch (SQLException e) { handleException(e); }
}
|
public void rollback() throws SQLException {
checkOpen(); try { _conn.rollback(); } catch (SQLException e) { handleException(e); }
}
|
public void rollback(Savepoint savepoint) throws SQLException {
checkOpen(); try { _conn.rollback(savepoint); } catch (SQLException e) { handleException(e); }
}
|
public void setAutoCommit(boolean autoCommit) throws SQLException {
checkOpen(); try { _conn.setAutoCommit(autoCommit); } catch (SQLException e) { handleException(e); }
}
|
public void setCatalog(String catalog) throws SQLException {
checkOpen(); try { _conn.setCatalog(catalog); } catch (SQLException e) { handleException(e); }
}
|
public void setDelegate(Connection c) {
_conn = c;
}
|
public void setHoldability(int holdability) throws SQLException {
checkOpen(); try { _conn.setHoldability(holdability); } catch (SQLException e) { handleException(e); }
}
|
public void setReadOnly(boolean readOnly) throws SQLException {
checkOpen(); try { _conn.setReadOnly(readOnly); } catch (SQLException e) { handleException(e); }
}
|
public Savepoint setSavepoint() throws SQLException {
checkOpen(); try { return _conn.setSavepoint(); } catch (SQLException e) { handleException(e); return null; }
}
|
public Savepoint setSavepoint(String name) throws SQLException {
checkOpen(); try { return _conn.setSavepoint(name); } catch (SQLException e) { handleException(e); return null; }
}
|
public void setTransactionIsolation(int level) throws SQLException {
checkOpen(); try { _conn.setTransactionIsolation(level); } catch (SQLException e) { handleException(e); }
}
|
public void setTypeMap(Map map) throws SQLException {
checkOpen(); try { _conn.setTypeMap(map); } catch (SQLException e) { handleException(e); }
}
|
public String toString() {
String s = null;
Connection c = this.getInnermostDelegate();
if (c != null) {
try {
if (c.isClosed()) {
s = "connection is closed";
}
else {
DatabaseMetaData meta = c.getMetaData();
if (meta != null) {
StringBuffer sb = new StringBuffer();
sb.append(meta.getURL());
sb.append(", UserName=");
sb.append(meta.getUserName());
sb.append(", ");
sb.append(meta.getDriverName());
s = sb.toString();
}
}
}
catch (SQLException ex) {
s = null;
}
}
if (s == null) {
s = super.toString();
}
return s;
}
Returns a string representation of the metadata associated with
the innnermost delegate connection. |