The following document contains the results of PMD's CPD 4.1.
| File | Line |
|---|---|
| org/apache/commons/dbcp/PoolingDataSource.java | 289 |
| org/apache/commons/dbcp/PoolingDriver.java | 348 |
}
public boolean isReadOnly() throws SQLException {
checkOpen();
return delegate.isReadOnly();
}
public String nativeSQL(String sql) throws SQLException {
checkOpen();
return delegate.nativeSQL(sql);
}
public CallableStatement prepareCall(String sql) throws SQLException {
checkOpen();
return new DelegatingCallableStatement(this, delegate.prepareCall(sql));
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
checkOpen();
return new DelegatingCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency));
}
public PreparedStatement prepareStatement(String sql) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql));
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, resultSetConcurrency));
}
public void rollback() throws SQLException {
checkOpen();
delegate.rollback();
}
public void setAutoCommit(boolean autoCommit) throws SQLException {
checkOpen();
delegate.setAutoCommit(autoCommit);
}
public void setCatalog(String catalog) throws SQLException {
checkOpen();
delegate.setCatalog(catalog);
}
public void setReadOnly(boolean readOnly) throws SQLException {
checkOpen();
delegate.setReadOnly(readOnly);
}
public void setTransactionIsolation(int level) throws SQLException {
checkOpen();
delegate.setTransactionIsolation(level);
}
public void setTypeMap(Map map) throws SQLException {
checkOpen();
delegate.setTypeMap(map);
}
public String toString() {
if (delegate == null){
return "NULL";
}
return delegate.toString();
}
// ------------------- JDBC 3.0 -----------------------------------------
// Will be commented by the build process on a JDBC 2.0 system
/* JDBC_3_ANT_KEY_BEGIN */
public int getHoldability() throws SQLException {
checkOpen();
return delegate.getHoldability();
}
public void setHoldability(int holdability) throws SQLException {
checkOpen();
delegate.setHoldability(holdability);
}
public java.sql.Savepoint setSavepoint() throws SQLException {
checkOpen();
return delegate.setSavepoint();
}
public java.sql.Savepoint setSavepoint(String name) throws SQLException {
checkOpen();
return delegate.setSavepoint(name);
}
public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException {
checkOpen();
delegate.releaseSavepoint(savepoint);
}
public void rollback(java.sql.Savepoint savepoint) throws SQLException {
checkOpen();
delegate.rollback(savepoint);
}
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
checkOpen();
return new DelegatingStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability));
}
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
checkOpen();
return new DelegatingCallableStatement(this, delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql, autoGeneratedKeys));
}
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability));
}
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql, columnIndexes));
}
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
checkOpen();
return new DelegatingPreparedStatement(this, delegate.prepareStatement(sql, columnNames));
}
/* JDBC_3_ANT_KEY_END */
/**
* @see org.apache.commons.dbcp.DelegatingConnection#getDelegate()
*/
public Connection getDelegate() {
if (isAccessToUnderlyingConnectionAllowed()) {
return super.getDelegate();
} else {
return null;
}
}
/**
* @see org.apache.commons.dbcp.DelegatingConnection#getInnermostDelegate()
*/
public Connection getInnermostDelegate() {
if (isAccessToUnderlyingConnectionAllowed()) {
return super.getInnermostDelegate();
} else {
return null;
}
}
}
}
| |
| File | Line |
|---|---|
| org/apache/commons/dbcp/datasources/CPDSConnectionFactory.java | 214 |
| org/apache/commons/dbcp/datasources/KeyedCPDSConnectionFactory.java | 211 |
public boolean validateObject(Object key, Object obj) {
boolean valid = false;
if (obj instanceof PooledConnectionAndInfo) {
PooledConnection pconn =
((PooledConnectionAndInfo)obj).getPooledConnection();
String query = _validationQuery;
if (null != query) {
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
// logical Connection from the PooledConnection must be closed
// before another one can be requested and closing it will
// generate an event. Keep track so we know not to return
// the PooledConnection
validatingMap.put(pconn, null);
try {
conn = pconn.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery(query);
if (rset.next()) {
valid = true;
} else {
valid = false;
}
if (_rollbackAfterValidation) {
conn.rollback();
}
} catch(Exception e) {
valid = false;
} finally {
if (rset != null) {
try {
rset.close();
} catch (Throwable t) {
// ignore
}
}
if (stmt != null) {
try {
stmt.close();
} catch (Throwable t) {
// ignore
}
}
if (conn != null) {
try {
conn.close();
} catch (Throwable t) {
// ignore
}
}
validatingMap.remove(pconn);
}
} else {
valid = true;
}
} else {
valid = false;
}
return valid;
}
public void passivateObject(Object key, Object obj) {
| |
| File | Line |
|---|---|
| org/apache/commons/dbcp/PoolingDataSource.java | 180 |
| org/apache/commons/dbcp/PoolingDriver.java | 262 |
this.delegate = delegate;
}
protected void checkOpen() throws SQLException {
if(delegate == null) {
throw new SQLException("Connection is closed.");
}
}
public void close() throws SQLException {
if (delegate != null) {
this.delegate.close();
this.delegate = null;
super.setDelegate(null);
}
}
public boolean isClosed() throws SQLException {
if (delegate == null) {
return true;
}
return delegate.isClosed();
}
public void clearWarnings() throws SQLException {
checkOpen();
delegate.clearWarnings();
}
public void commit() throws SQLException {
checkOpen();
delegate.commit();
}
public Statement createStatement() throws SQLException {
checkOpen();
return new DelegatingStatement(this, delegate.createStatement());
}
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
checkOpen();
return new DelegatingStatement(this, delegate.createStatement(resultSetType, resultSetConcurrency));
}
public boolean equals(Object obj) {
| |
| File | Line |
|---|---|
| org/apache/commons/dbcp/PoolableCallableStatement.java | 87 |
| org/apache/commons/dbcp/PoolablePreparedStatement.java | 102 |
throw new SQLNestedException("Cannot close preparedstatement (return to pool failed)", e);
}
}
}
protected void activate() throws SQLException{
_closed = false;
if(_conn != null) {
_conn.addTrace(this);
}
super.activate();
}
protected void passivate() throws SQLException {
_closed = true;
if(_conn != null) {
_conn.removeTrace(this);
}
// The JDBC spec requires that a statment close any open
// ResultSet's when it is closed.
// FIXME The PreparedStatement we're wrapping should handle this for us.
// See bug 17301 for what could happen when ResultSets are closed twice.
List resultSets = getTrace();
if( resultSets != null) {
ResultSet[] set = (ResultSet[]) resultSets.toArray(new ResultSet[resultSets.size()]);
for (int i = 0; i < set.length; i++) {
set[i].close();
}
clearTrace();
}
| |