|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jcreme.sql.WrappedStatement
This class enables to wrap an actual statement to provide a few extra services: tracing of the queries, handling of some exceptions (rollback, loss of connection). The ResultSets provided by this class are wrapped around the actual ResultSet.
Field Summary | |
protected java.lang.String |
baseQuery
The initial query assigned to the Statement. |
protected java.util.Vector |
batchRequests
This vector enables to store the queries contained in a batch statement. |
protected java.sql.Statement |
realStatement
The underlying statement. |
protected static java.lang.String |
UNKNOWN_QUERY
The String displayed when no query has been assigned to the Statement yet. |
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 | |
WrappedStatement(java.sql.Statement statement)
Enables to wrap a Statement. |
Method Summary | |
void |
addBatch(java.lang.String sql)
|
void |
cancel()
|
void |
clearBatch()
|
void |
clearWarnings()
|
void |
close()
|
boolean |
execute(java.lang.String sql)
|
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()
|
java.sql.ResultSet |
executeQuery(java.lang.String sql)
|
int |
executeUpdate(java.lang.String sql)
|
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)
|
protected ConnectionLostException |
generateConnectionLostException(java.lang.String message,
java.sql.SQLException e)
This method generates a ConnectionLostException from an SQLException. |
protected DeadLockException |
generateDeadLockException(java.lang.String message,
java.sql.SQLException e)
This method generates a DeadLockException from an SQLException. |
protected java.sql.SQLException |
generateException(java.sql.SQLException e)
This method enables to generate an SQLException that contains the query of the statement in its message. |
protected java.sql.SQLException |
generateException(java.lang.String message,
java.sql.SQLException e)
This method enables to append a message to the original exception's message. |
protected java.sql.SQLException |
generateNewException(java.lang.String message,
java.sql.BatchUpdateException e)
This method generates a BatchUpdateException from an SQLException. |
protected java.sql.SQLException |
generateNewException(java.lang.String message,
java.sql.SQLException e)
This method generates a new SQLException from an SQLException. |
protected java.lang.String |
getBatchRequestAt(int i)
This method gives access to the batch query at the given index. |
java.sql.Connection |
getConnection()
|
int |
getFetchDirection()
|
int |
getFetchSize()
|
java.sql.ResultSet |
getGeneratedKeys()
|
int |
getMaxFieldSize()
|
int |
getMaxRows()
|
boolean |
getMoreResults()
|
boolean |
getMoreResults(int current)
|
int |
getQueryTimeout()
|
java.sql.ResultSet |
getResultSet()
|
int |
getResultSetConcurrency()
|
int |
getResultSetHoldability()
|
int |
getResultSetType()
|
int |
getUpdateCount()
|
java.sql.SQLWarning |
getWarnings()
|
protected int |
manageException(java.sql.SQLException e)
This method enables to call upon an ExceptionHandler to manage the given exception. |
protected int |
manageException(java.sql.SQLException e,
CremeAction redo)
This method enables to call upon an ExceptionHandler to manage the given exception. |
protected void |
setBaseQuery(java.lang.String sql)
This method enables to set the base query of the statement. |
void |
setCursorName(java.lang.String name)
|
void |
setEscapeProcessing(boolean enable)
|
void |
setFetchDirection(int direction)
|
void |
setFetchSize(int rows)
|
void |
setMaxFieldSize(int max)
|
void |
setMaxRows(int i)
|
void |
setQueryTimeout(int seconds)
|
protected void |
setRealStatement(java.sql.Statement statement)
This method should be used by subclasses to set the realStatement. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String UNKNOWN_QUERY
protected java.sql.Statement realStatement
protected final java.util.Vector batchRequests
protected java.lang.String baseQuery
Constructor Detail |
public WrappedStatement(java.sql.Statement statement) throws java.sql.SQLException
statement
- the statement to wrap.
java.sql.SQLException
- if the statement is null.Method Detail |
protected void setRealStatement(java.sql.Statement statement) throws java.sql.SQLException
statement
- the statement to wrap.
java.sql.SQLException
- if the statement is null.protected void setBaseQuery(java.lang.String sql) throws java.sql.SQLException
sql
- the sql query underlying the statement.
java.sql.SQLException
- if the query is null.protected java.sql.SQLException generateException(java.sql.SQLException e)
e
- the original exception.
protected java.sql.SQLException generateException(java.lang.String message, java.sql.SQLException e)
message
- the message to append.e
- the original exception.
protected DeadLockException generateDeadLockException(java.lang.String message, java.sql.SQLException e)
message
- the message to append.e
- the original exception.
protected ConnectionLostException generateConnectionLostException(java.lang.String message, java.sql.SQLException e)
message
- the message to append.e
- the original exception.
protected java.sql.SQLException generateNewException(java.lang.String message, java.sql.SQLException e)
message
- the message to append.e
- the original exception.
protected java.sql.SQLException generateNewException(java.lang.String message, java.sql.BatchUpdateException e)
message
- the message to append.e
- the original exception.
protected int manageException(java.sql.SQLException e)
e
- exception to handle.
protected int manageException(java.sql.SQLException e, CremeAction redo)
e
- exception to handle.redo
- the action that caused the original exception.
public java.sql.ResultSet executeQuery(java.lang.String sql) throws java.sql.SQLException
executeQuery
in interface java.sql.Statement
java.sql.SQLException
Statement.executeQuery(java.lang.String)
public int executeUpdate(java.lang.String sql) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
Statement.executeUpdate(java.lang.String)
public void close() throws java.sql.SQLException
close
in interface java.sql.Statement
java.sql.SQLException
Statement.close()
public int getMaxFieldSize() throws java.sql.SQLException
getMaxFieldSize
in interface java.sql.Statement
java.sql.SQLException
Statement.getMaxFieldSize()
public void setMaxFieldSize(int max) throws java.sql.SQLException
setMaxFieldSize
in interface java.sql.Statement
java.sql.SQLException
Statement.setMaxFieldSize(int)
public int getMaxRows() throws java.sql.SQLException
getMaxRows
in interface java.sql.Statement
java.sql.SQLException
Statement.getMaxRows()
public void setMaxRows(int i) throws java.sql.SQLException
setMaxRows
in interface java.sql.Statement
java.sql.SQLException
Statement.setMaxRows(int)
public void setEscapeProcessing(boolean enable) throws java.sql.SQLException
setEscapeProcessing
in interface java.sql.Statement
java.sql.SQLException
Statement.setEscapeProcessing(boolean)
public int getQueryTimeout() throws java.sql.SQLException
getQueryTimeout
in interface java.sql.Statement
java.sql.SQLException
Statement.getQueryTimeout()
public void setQueryTimeout(int seconds) throws java.sql.SQLException
setQueryTimeout
in interface java.sql.Statement
java.sql.SQLException
Statement.setQueryTimeout(int)
public void cancel() throws java.sql.SQLException
cancel
in interface java.sql.Statement
java.sql.SQLException
Statement.cancel()
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Statement
java.sql.SQLException
Statement.getWarnings()
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Statement
java.sql.SQLException
Statement.clearWarnings()
public void setCursorName(java.lang.String name) throws java.sql.SQLException
setCursorName
in interface java.sql.Statement
java.sql.SQLException
Statement.setCursorName(java.lang.String)
public boolean execute(java.lang.String sql) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
Statement.execute(java.lang.String)
public java.sql.ResultSet getResultSet() throws java.sql.SQLException
getResultSet
in interface java.sql.Statement
java.sql.SQLException
Statement.getResultSet()
public int getUpdateCount() throws java.sql.SQLException
getUpdateCount
in interface java.sql.Statement
java.sql.SQLException
Statement.getUpdateCount()
public boolean getMoreResults() throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
java.sql.SQLException
Statement.getMoreResults()
public void setFetchDirection(int direction) throws java.sql.SQLException
setFetchDirection
in interface java.sql.Statement
java.sql.SQLException
Statement.setFetchDirection(int)
public int getFetchDirection() throws java.sql.SQLException
getFetchDirection
in interface java.sql.Statement
java.sql.SQLException
Statement.getFetchDirection()
public void setFetchSize(int rows) throws java.sql.SQLException
setFetchSize
in interface java.sql.Statement
java.sql.SQLException
Statement.setFetchSize(int)
public int getFetchSize() throws java.sql.SQLException
getFetchSize
in interface java.sql.Statement
java.sql.SQLException
Statement.getFetchSize()
public int getResultSetConcurrency() throws java.sql.SQLException
getResultSetConcurrency
in interface java.sql.Statement
java.sql.SQLException
Statement.getResultSetConcurrency()
public int getResultSetType() throws java.sql.SQLException
getResultSetType
in interface java.sql.Statement
java.sql.SQLException
Statement.getResultSetType()
public void addBatch(java.lang.String sql) throws java.sql.SQLException
addBatch
in interface java.sql.Statement
java.sql.SQLException
Statement.addBatch(java.lang.String)
public void clearBatch() throws java.sql.SQLException
clearBatch
in interface java.sql.Statement
java.sql.SQLException
Statement.clearBatch()
public int[] executeBatch() throws java.sql.SQLException
executeBatch
in interface java.sql.Statement
java.sql.SQLException
Statement.executeBatch()
protected java.lang.String getBatchRequestAt(int i)
i
- the index of the batch query to find.
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface java.sql.Statement
java.sql.SQLException
Statement.getConnection()
public boolean getMoreResults(int current) throws java.sql.SQLException
getMoreResults
in interface java.sql.Statement
java.sql.SQLException
Statement.getMoreResults(int)
public java.sql.ResultSet getGeneratedKeys() throws java.sql.SQLException
getGeneratedKeys
in interface java.sql.Statement
java.sql.SQLException
Statement.getGeneratedKeys()
public int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
Statement.executeUpdate(java.lang.String, int)
public int executeUpdate(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
Statement.executeUpdate(java.lang.String, int[])
public int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
executeUpdate
in interface java.sql.Statement
java.sql.SQLException
Statement.executeUpdate(java.lang.String, java.lang.String[])
public boolean execute(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
Statement.execute(java.lang.String, int)
public boolean execute(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
Statement.execute(java.lang.String, int[])
public boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
execute
in interface java.sql.Statement
java.sql.SQLException
Statement.execute(java.lang.String, java.lang.String[])
public int getResultSetHoldability() throws java.sql.SQLException
getResultSetHoldability
in interface java.sql.Statement
java.sql.SQLException
Statement.getResultSetHoldability()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |