|
|||||||||
| Home >> All >> org >> apache >> commons >> [ dbcp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.commons.dbcp
Class DelegatingStatement

java.lang.Objectorg.apache.commons.dbcp.AbandonedTrace
org.apache.commons.dbcp.DelegatingStatement
- All Implemented Interfaces:
- java.sql.Statement
- Direct Known Subclasses:
- DelegatingPreparedStatement
- public class DelegatingStatement
- extends AbandonedTrace
- implements java.sql.Statement
- extends AbandonedTrace
A base delegating implementation of java.sql.Statement.
All of the methods from the java.sql.Statement interface simply check to see that the java.sql.Statement is active, and call the corresponding method on the "delegate" provided in my constructor.
Extends AbandonedTrace to implement Statement tracking and logging of code which created the Statement. Tracking the Statement ensures that the Connection which created it can close any open Statement's on Connection close.
- Version:
- $Revision: 1.17 $ $Date: 2004/03/06 13:35:31 $
| Field Summary | |
protected boolean |
_closed
|
protected DelegatingConnection |
_conn
The connection that created me. |
protected java.sql.Statement |
_stmt
My delegate. |
| Fields inherited from class org.apache.commons.dbcp.AbandonedTrace |
|
| Fields inherited from interface java.sql.Statement |
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO |
| Constructor Summary | |
DelegatingStatement(DelegatingConnection c,
java.sql.Statement s)
Create a wrapper for the Statement which traces this Statement to the Connection which created it and the code which created it. |
|
| Method Summary | |
protected void |
activate()
|
void |
addBatch(java.lang.String sql)
This method adds a SQL statement to a SQL batch. |
void |
cancel()
This method cancels an outstanding statement, if the database supports that operation. |
protected void |
checkOpen()
|
void |
clearBatch()
This method clears out any SQL statements that have been populated in the current batch. |
void |
clearWarnings()
This method clears any SQL warnings that have been attached to this statement. |
void |
close()
Close this DelegatingStatement, and close any ResultSets that were not explicitly closed. |
boolean |
equals(java.lang.Object obj)
Determine whether this Object is semantically equal to another Object. |
boolean |
execute(java.lang.String sql)
This method executes an arbitrary SQL statement of any time. |
boolean |
execute(java.lang.String sql,
int autoGeneratedKeys)
|
boolean |
execute(java.lang.String sql,
int[] columnIndexes)
|
boolean |
execute(java.lang.String sql,
java.lang.String[] columnNames)
|
int[] |
executeBatch()
This method executes the SQL batch and returns an array of update counts - one for each SQL statement in the batch - ordered in the same order the statements were added to the batch. |
java.sql.ResultSet |
executeQuery(java.lang.String sql)
This method executes the specified SQL SELECT statement and returns a (possibly empty) ResultSet with the results of the query. |
int |
executeUpdate(java.lang.String sql)
This method executes the specified SQL INSERT, UPDATE, or DELETE statement and returns the number of rows affected, which may be 0. |
int |
executeUpdate(java.lang.String sql,
int autoGeneratedKeys)
|
int |
executeUpdate(java.lang.String sql,
int[] columnIndexes)
|
int |
executeUpdate(java.lang.String sql,
java.lang.String[] columnNames)
|
java.sql.Connection |
getConnection()
This method returns the Connection instance that was
used to create this object. |
java.sql.Statement |
getDelegate()
Returns my underlying java.sql.Statement. |
int |
getFetchDirection()
This method returns the current direction that the driver thinks the result set will be accessed int. |
int |
getFetchSize()
This method returns the number of rows the driver believes should be fetched from the database at a time. |
java.sql.ResultSet |
getGeneratedKeys()
|
java.sql.Statement |
getInnermostDelegate()
If my underlying java.sql.Statement is not a DelegatingStatement, returns it, otherwise recursively invokes this method on my delegate. |
int |
getMaxFieldSize()
This method returns the maximum length of any column value in bytes. |
int |
getMaxRows()
This method returns the maximum possible number of rows in a result set. |
boolean |
getMoreResults()
This method advances the result set pointer to the next result set, which can then be retrieved using getResultSet |
boolean |
getMoreResults(int current)
|
int |
getQueryTimeout()
The method returns the number of seconds a statement may be in process before timing out. |
java.sql.ResultSet |
getResultSet()
This method returns the result set of the SQL statement that was executed. |
int |
getResultSetConcurrency()
This method returns the concurrency type of the result set for this statement. |
int |
getResultSetHoldability()
|
int |
getResultSetType()
This method returns the result set type for this statement. |
int |
getUpdateCount()
This method returns the update count of the SQL statement that was executed. |
java.sql.SQLWarning |
getWarnings()
This method returns the first SQL warning attached to this statement. |
protected void |
handleException(java.sql.SQLException e)
|
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
protected boolean |
isClosed()
|
protected void |
passivate()
|
void |
setCursorName(java.lang.String name)
This method sets the cursor name that will be used by the result set. |
void |
setDelegate(java.sql.Statement s)
Sets my delegate. |
void |
setEscapeProcessing(boolean enable)
This method sets the local escape processing mode on or off. |
void |
setFetchDirection(int direction)
This method informs the driver which direction the result set will be accessed in. |
void |
setFetchSize(int rows)
This method informs the driver how many rows it should fetch from the database at a time. |
void |
setMaxFieldSize(int max)
This method sets the limit for the maximum length of any column in bytes. |
void |
setMaxRows(int max)
This method sets the maximum number of rows that can be present in a result set. |
void |
setQueryTimeout(int seconds)
This method sets the number of seconds a statement may be in process before timing out. |
| Methods inherited from class org.apache.commons.dbcp.AbandonedTrace |
addTrace, clearTrace, getConfig, getLastUsed, getTrace, printStackTrace, removeTrace, setLastUsed, setLastUsed, setStackTrace |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
_stmt
protected java.sql.Statement _stmt
- My delegate.
_conn
protected DelegatingConnection _conn
- The connection that created me.
_closed
protected boolean _closed
| Constructor Detail |
DelegatingStatement
public DelegatingStatement(DelegatingConnection c, java.sql.Statement s)
- Create a wrapper for the Statement which traces this
Statement to the Connection which created it and the
code which created it.
| Method Detail |
getDelegate
public java.sql.Statement getDelegate()
- Returns my underlying java.sql.Statement.
equals
public boolean equals(java.lang.Object obj)
- Description copied from class:
java.lang.Object - Determine whether this Object is semantically equal
to another Object.
There are some fairly strict requirements on this method which subclasses must follow:
- It must be transitive. If
a.equals(b)andb.equals(c), thena.equals(c)must be true as well. - It must be symmetric.
a.equals(b)andb.equals(a)must have the same value. - It must be reflexive.
a.equals(a)must always be true. - It must be consistent. Whichever value a.equals(b) returns on the first invocation must be the value returned on all later invocations.
a.equals(null)must be false.- It must be consistent with hashCode(). That is,
a.equals(b)must implya.hashCode() == b.hashCode(). The reverse is not true; two objects that are not equal may have the same hashcode, but that has the potential to harm hashing performance.
This is typically overridden to throw a java.lang.ClassCastException if the argument is not comparable to the class performing the comparison, but that is not a requirement. It is legal for
a.equals(b)to be true even thougha.getClass() != b.getClass(). Also, it is typical to never cause a java.lang.NullPointerException.In general, the Collections API (
java.util) use theequalsmethod rather than the==operator to compare objects. However, java.util.IdentityHashMap is an exception to this rule, for its own good reasons.The default implementation returns
this == o. - It must be transitive. If
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
getInnermostDelegate
public java.sql.Statement getInnermostDelegate()
- If my underlying java.sql.Statement is not a
DelegatingStatement, returns it,
otherwise recursively invokes this method on
my delegate.
Hence this method will return the first delegate that is not a DelegatingStatement or null when no non-DelegatingStatement delegate can be found by transversing this chain.
This method is useful when you may have nested DelegatingStatements, and you want to make sure to obtain a "genuine" java.sql.Statement.
setDelegate
public void setDelegate(java.sql.Statement s)
- Sets my delegate.
isClosed
protected boolean isClosed()
checkOpen
protected void checkOpen()
throws java.sql.SQLException
close
public void close()
throws java.sql.SQLException
- Close this DelegatingStatement, and close
any ResultSets that were not explicitly closed.
- Specified by:
closein interfacejava.sql.Statement
handleException
protected void handleException(java.sql.SQLException e) throws java.sql.SQLException
activate
protected void activate()
throws java.sql.SQLException
passivate
protected void passivate()
throws java.sql.SQLException
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the
Connectioninstance that was used to create this object.- Specified by:
getConnectionin interfacejava.sql.Statement
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method executes the specified SQL SELECT statement and returns a
(possibly empty)
ResultSetwith the results of the query.- Specified by:
executeQueryin interfacejava.sql.Statement
getResultSet
public java.sql.ResultSet getResultSet() throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the result set of the SQL statement that was
executed. This should be called only once per result set returned.
- Specified by:
getResultSetin interfacejava.sql.Statement
executeUpdate
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method executes the specified SQL INSERT, UPDATE, or DELETE statement
and returns the number of rows affected, which may be 0.
- Specified by:
executeUpdatein interfacejava.sql.Statement
getMaxFieldSize
public int getMaxFieldSize()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the maximum length of any column value in bytes.
- Specified by:
getMaxFieldSizein interfacejava.sql.Statement
setMaxFieldSize
public void setMaxFieldSize(int max)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method sets the limit for the maximum length of any column in bytes.
- Specified by:
setMaxFieldSizein interfacejava.sql.Statement
getMaxRows
public int getMaxRows()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the maximum possible number of rows in a result set.
- Specified by:
getMaxRowsin interfacejava.sql.Statement
setMaxRows
public void setMaxRows(int max)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method sets the maximum number of rows that can be present in a
result set.
- Specified by:
setMaxRowsin interfacejava.sql.Statement
setEscapeProcessing
public void setEscapeProcessing(boolean enable)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method sets the local escape processing mode on or off. The
default value is on.
- Specified by:
setEscapeProcessingin interfacejava.sql.Statement
getQueryTimeout
public int getQueryTimeout()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - The method returns the number of seconds a statement may be in process
before timing out. A value of 0 means there is no timeout.
- Specified by:
getQueryTimeoutin interfacejava.sql.Statement
setQueryTimeout
public void setQueryTimeout(int seconds)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method sets the number of seconds a statement may be in process
before timing out. A value of 0 means there is no timeout.
- Specified by:
setQueryTimeoutin interfacejava.sql.Statement
cancel
public void cancel()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method cancels an outstanding statement, if the database supports
that operation.
- Specified by:
cancelin interfacejava.sql.Statement
getWarnings
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the first SQL warning attached to this statement.
Subsequent warnings will be chained to this one.
- Specified by:
getWarningsin interfacejava.sql.Statement
clearWarnings
public void clearWarnings()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method clears any SQL warnings that have been attached to this
statement.
- Specified by:
clearWarningsin interfacejava.sql.Statement
setCursorName
public void setCursorName(java.lang.String name) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method sets the cursor name that will be used by the result set.
- Specified by:
setCursorNamein interfacejava.sql.Statement
execute
public boolean execute(java.lang.String sql) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method executes an arbitrary SQL statement of any time. The
methods
getResultSet,getMoreResultsandgetUpdateCountretrieve the results.- Specified by:
executein interfacejava.sql.Statement
getUpdateCount
public int getUpdateCount()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the update count of the SQL statement that was
executed. This should be called only once per executed SQL statement.
- Specified by:
getUpdateCountin interfacejava.sql.Statement
getMoreResults
public boolean getMoreResults()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method advances the result set pointer to the next result set,
which can then be retrieved using
getResultSet- Specified by:
getMoreResultsin interfacejava.sql.Statement
setFetchDirection
public void setFetchDirection(int direction)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method informs the driver which direction the result set will
be accessed in.
- Specified by:
setFetchDirectionin interfacejava.sql.Statement
getFetchDirection
public int getFetchDirection()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the current direction that the driver thinks the
result set will be accessed int.
- Specified by:
getFetchDirectionin interfacejava.sql.Statement
setFetchSize
public void setFetchSize(int rows)
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method informs the driver how many rows it should fetch from the
database at a time.
- Specified by:
setFetchSizein interfacejava.sql.Statement
getFetchSize
public int getFetchSize()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the number of rows the driver believes should be
fetched from the database at a time.
- Specified by:
getFetchSizein interfacejava.sql.Statement
getResultSetConcurrency
public int getResultSetConcurrency()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the concurrency type of the result set for this
statement. This will be one of the concurrency types defined in
ResultSet.- Specified by:
getResultSetConcurrencyin interfacejava.sql.Statement
getResultSetType
public int getResultSetType()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method returns the result set type for this statement. This will
be one of the result set types defined in
ResultSet.- Specified by:
getResultSetTypein interfacejava.sql.Statement
addBatch
public void addBatch(java.lang.String sql) throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method adds a SQL statement to a SQL batch. A driver is not
required to implement this method.
- Specified by:
addBatchin interfacejava.sql.Statement
clearBatch
public void clearBatch()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method clears out any SQL statements that have been populated in
the current batch. A driver is not required to implement this method.
- Specified by:
clearBatchin interfacejava.sql.Statement
executeBatch
public int[] executeBatch()
throws java.sql.SQLException
- Description copied from interface:
java.sql.Statement - This method executes the SQL batch and returns an array of update
counts - one for each SQL statement in the batch - ordered in the same
order the statements were added to the batch. A driver is not required
to implement this method.
- Specified by:
executeBatchin interfacejava.sql.Statement
getMoreResults
public boolean getMoreResults(int current)
throws java.sql.SQLException
- Specified by:
getMoreResultsin interfacejava.sql.Statement
getGeneratedKeys
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException
- Specified by:
getGeneratedKeysin interfacejava.sql.Statement
executeUpdate
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
- Specified by:
executeUpdatein interfacejava.sql.Statement
executeUpdate
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
- Specified by:
executeUpdatein interfacejava.sql.Statement
executeUpdate
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
- Specified by:
executeUpdatein interfacejava.sql.Statement
execute
public boolean execute(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
- Specified by:
executein interfacejava.sql.Statement
execute
public boolean execute(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
- Specified by:
executein interfacejava.sql.Statement
execute
public boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
- Specified by:
executein interfacejava.sql.Statement
getResultSetHoldability
public int getResultSetHoldability()
throws java.sql.SQLException
- Specified by:
getResultSetHoldabilityin interfacejava.sql.Statement
|
|||||||||
| Home >> All >> org >> apache >> commons >> [ dbcp overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC