Class BrokeredStatement
- All Implemented Interfaces:
AutoCloseable, Statement, Wrapper, EngineStatement
- Direct Known Subclasses:
BrokeredPreparedStatement
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final BrokeredStatementControlMy control.private StringMy stateprivate Boolean(package private) final int(package private) final int(package private) final intFields inherited from interface Statement
CLOSE_ALL_RESULTS, CLOSE_CURRENT_RESULT, EXECUTE_FAILED, KEEP_CURRENT_RESULT, NO_GENERATED_KEYS, RETURN_GENERATED_KEYS, SUCCESS_NO_INFO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidfinal voidcancel()protected final voidChecks if the statement is closed and throws an exception if it is.final voidfinal voidAfter this call getWarnings returns null until a new warning is reported for this Statement.voidclose()In many cases, it is desirable to immediately release a Statements's database and JDBC resources instead of waiting for this to happen when it is automatically closed; the close method provides this immediate release.void/////////////////////////////////////////////////////////////////(package private) final BrokeredStatementControlGet the BrokeredStatementControl in order to perform a check.createDuplicateStatement(Connection conn, Statement oldStatement) final booleanfinal booleanfinal booleanfinal booleanfinal int[]long[]/////////////////////////////////////////////////////////////////longexecuteLargeUpdate(String sql) longexecuteLargeUpdate(String sql, int autoGeneratedKeys) longexecuteLargeUpdate(String sql, int[] columnIndexes) longexecuteLargeUpdate(String sql, String[] columnNames) final ResultSetexecuteQuery(String sql) final intexecuteUpdate(String sql) final intexecuteUpdate(String sql, int autoGeneratedKeys) final intexecuteUpdate(String sql, int[] columnIndexes) final intexecuteUpdate(String sql, String[] columnNames) final Connectionfinal intfinal intfinal ResultSetJDBC 3.0 Retrieves any auto-generated keys created as a result of executing this Statement object.longlongfinal intfinal intfinal booleangetMoreResults moves to a Statement's next result.final booleangetMoreResults(int current) JDBC 3.0 Moves to this Statement obect's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet objectfinal intfinal ResultSetgetResultSet returns the current result as a ResultSet.final intfinal intReturn the holdability of ResultSets created by this Statement.final intJDBC 2.0 Determine the result set type.final intgetUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned.final SQLWarningThe first warning reported by calls on this Statement is returned.final booleanisClosed()Checks if the statement is closed.booleanfinal booleanForwards to the real Statement.booleanisWrapperFor(Class iface) Returns false unlessifaceis implementedfinal voidsetCursorName(String name) setCursorName defines the SQL cursor name that will be used by subsequent Statement execute methods.final voidsetEscapeProcessing(boolean enable) If escape scanning is on (the default) the driver will do escape substitution before sending the SQL to the database.final voidsetFetchDirection(int direction) JDBC 2.0 Give a hint as to the direction in which the rows in a result set will be processed.final voidsetFetchSize(int rows) JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed.voidsetLargeMaxRows(long max) final voidsetMaxFieldSize(int max) The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields.final voidsetMaxRows(int max) The maxRows limit is set to limit the number of rows that any ResultSet can contain.final voidsetPoolable(boolean poolable) Forwards to the real Statement.final voidsetQueryTimeout(int seconds) (package private) voidsetStatementState(Statement oldStatement, Statement newStatement) (package private) final SQLExceptionunableToUnwrap(Class iface) Return an exception that reports that an unwrap operation has failed because the object couldn't be cast to the specified interface.<T> TReturnsthisif this class implements the specified interface.(package private) final ResultSetProvide the control access to every ResultSet we return.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, isSimpleIdentifier
-
Field Details
-
control
My control. Use the controlCheck() method to obtain the control when calling a check method. This will result in the correct exception being thrown if the statement is already closed. -
resultSetType
final int resultSetType -
resultSetConcurrency
final int resultSetConcurrency -
resultSetHoldability
final int resultSetHoldability -
cursorName
My state -
escapeProcessing
-
-
Constructor Details
-
BrokeredStatement
BrokeredStatement(BrokeredStatementControl control) throws SQLException - Throws:
SQLException
-
-
Method Details
-
addBatch
- Specified by:
addBatchin interfaceStatement- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatchin interfaceStatement- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatchin interfaceStatement- Throws:
SQLException
-
cancel
- Specified by:
cancelin interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
executeQuery
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
close
In many cases, it is desirable to immediately release a Statements's database and JDBC resources instead of waiting for this to happen when it is automatically closed; the close method provides this immediate release.Note: A Statement is automatically closed when it is garbage collected. When a Statement is closed its current ResultSet, if one exists, is also closed.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLException- thrown on failure.
-
getConnection
- Specified by:
getConnectionin interfaceStatement- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLException
-
getMaxFieldSize
- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLException
-
setMaxFieldSize
The maxFieldSize limit (in bytes) is set to limit the size of data that can be returned for any column value; it only applies to BINARY, VARBINARY, LONGVARBINARY, CHAR, VARCHAR, and LONGVARCHAR fields. If the limit is exceeded, the excess data is silently discarded.- Specified by:
setMaxFieldSizein interfaceStatement- Parameters:
max- the new max column size limit; zero means unlimited- Throws:
SQLException- thrown on failure.
-
setMaxRows
The maxRows limit is set to limit the number of rows that any ResultSet can contain. If the limit is exceeded, the excess rows are silently dropped.- Specified by:
setMaxRowsin interfaceStatement- Parameters:
max- the new max rows limit; zero means unlimited- Throws:
SQLException- thrown on failure.
-
setEscapeProcessing
If escape scanning is on (the default) the driver will do escape substitution before sending the SQL to the database.- Specified by:
setEscapeProcessingin interfaceStatement- Parameters:
enable- true to enable; false to disable- Throws:
SQLException- thrown on failure.
-
getWarnings
The first warning reported by calls on this Statement is returned. A Statment's execute methods clear its SQLWarning chain. Subsequent Statement warnings will be chained to this SQLWarning.The warning chain is automatically cleared each time a statement is (re)executed.
Note: If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
- Specified by:
getWarningsin interfaceStatement- Returns:
- the first SQLWarning or null
- Throws:
SQLException- thrown on failure.
-
clearWarnings
After this call getWarnings returns null until a new warning is reported for this Statement.- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLException- thrown on failure.
-
setCursorName
setCursorName defines the SQL cursor name that will be used by subsequent Statement execute methods. This name can then be used in SQL positioned update/delete statements to identify the current row in the ResultSet generated by this getStatement(). If the database doesn't support positioned update/delete, this method is a noop.Note: By definition, positioned update/delete execution must be done by a different Statement than the one which generated the ResultSet being used for positioning. Also, cursor names must be unique within a Connection.
- Specified by:
setCursorNamein interfaceStatement- Parameters:
name- the new cursor name.- Throws:
SQLException
-
getResultSet
getResultSet returns the current result as a ResultSet. It should only be called once per result.- Specified by:
getResultSetin interfaceStatement- Returns:
- the current result as a ResultSet; null if the result is an update count or there are no more results or the statement was closed.
- Throws:
SQLException- See Also:
-
getUpdateCount
getUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned. It should only be called once per result.The only way to tell for sure that the result is an update count is to first test to see if it is a ResultSet. If it is not a ResultSet it is either an update count or there are no more results.
- Specified by:
getUpdateCountin interfaceStatement- Returns:
- the current result as an update count; -1 if it is a ResultSet or there are no more results
- Throws:
SQLException- See Also:
-
getMoreResults
getMoreResults moves to a Statement's next result. It returns true if this result is a ResultSet. getMoreResults also implicitly closes any current ResultSet obtained with getResultSet. There are no more results when (!getMoreResults() && (getUpdateCount() == -1)- Specified by:
getMoreResultsin interfaceStatement- Returns:
- true if the next result is a ResultSet; false if it is an update count or there are no more results
- Throws:
SQLException- thrown on failure.- See Also:
-
getResultSetType
JDBC 2.0 Determine the result set type.- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLException- Feature not implemented for now.
-
setFetchDirection
JDBC 2.0 Give a hint as to the direction in which the rows in a result set will be processed. The hint applies only to result sets created using this Statement object. The default value is ResultSet.FETCH_FORWARD.- Specified by:
setFetchDirectionin interfaceStatement- Parameters:
direction- the initial direction for processing rows- Throws:
SQLException- if a database-access error occurs or direction is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN
-
setFetchSize
JDBC 2.0 Give the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified only affects result sets created using this getStatement(). If the value specified is zero, then the hint is ignored. The default value is zero.- Specified by:
setFetchSizein interfaceStatement- Parameters:
rows- the number of rows to fetch- Throws:
SQLException- if a database-access error occurs, or the condition 0 <= rows <= this.getMaxRows() is not satisfied.
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLException
-
getMoreResults
JDBC 3.0 Moves to this Statement obect's next result, deals with any current ResultSet object(s) according to the instructions specified by the given flag, and returns true if the next result is a ResultSet object- Specified by:
getMoreResultsin interfaceStatement- Parameters:
current- - one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSetCLOSE_CURRENT_RESULT, KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTS- Returns:
- true if the next result is a ResultSet; false if it is an update count or there are no more results
- Throws:
SQLException- thrown on failure.- See Also:
-
getGeneratedKeys
JDBC 3.0 Retrieves any auto-generated keys created as a result of executing this Statement object. If this Statement object did not generate any keys, an empty ResultSet object is returned. If this Statement is a non-insert statement, an exception will be thrown.- Specified by:
getGeneratedKeysin interfaceStatement- Returns:
- a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
- Throws:
SQLException- if a database access error occurs
-
getResultSetHoldability
Return the holdability of ResultSets created by this Statement. If this Statement is active in a global transaction the CLOSE_CURSORS_ON_COMMIT will be returned regardless of the holdability it was created with. In a local transaction the original create holdabilty will be returned.- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
createDuplicateStatement
public Statement createDuplicateStatement(Connection conn, Statement oldStatement) throws SQLException - Throws:
SQLException
-
setStatementState
- Throws:
SQLException
-
getStatement
- Throws:
SQLException
-
wrapResultSet
Provide the control access to every ResultSet we return. If required the control can wrap the ResultSet, but it (the control) must ensure a underlying ResultSet is only wrapped once, if say java.sql.Statement.getResultSet is returned twice.- Parameters:
rs- ResultSet being returned, can be null.
-
controlCheck
Get the BrokeredStatementControl in order to perform a check. Obtained indirectly to ensure that the correct exception is thrown if the Statement has been closed.- Throws:
SQLException
-
isWrapperFor
Returns false unlessifaceis implemented- Specified by:
isWrapperForin interfaceWrapper- Parameters:
iface- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
- Throws:
SQLException- if an error occurs while determining whether this is a wrapper for an object with the given interface.
-
unwrap
Returnsthisif this class implements the specified interface.- Specified by:
unwrapin interfaceWrapper- Parameters:
iface- a class defining an interface- Returns:
- an object that implements the interface
- Throws:
SQLException- if no object is found that implements the interface
-
isClosed
Checks if the statement is closed.- Specified by:
isClosedin interfaceStatement- Returns:
trueif the statement is closed,falseotherwise- Throws:
SQLException- if an error occurs
-
checkIfClosed
Checks if the statement is closed and throws an exception if it is.- Throws:
SQLException- if the statement is closed
-
unableToUnwrap
Return an exception that reports that an unwrap operation has failed because the object couldn't be cast to the specified interface.- Parameters:
iface- the class or interface passed in to the failed unwrap call- Returns:
- an exception indicating that unwrap failed
-
isPoolable
Forwards to the real Statement.- Specified by:
isPoolablein interfaceStatement- Returns:
- true if the underlying Statement is poolable, false otherwise.
- Throws:
SQLException- if the forwarding call fails.
-
setPoolable
Forwards to the real Statement.- Specified by:
setPoolablein interfaceStatement- Parameters:
poolable- the new value for the poolable hint.- Throws:
SQLException- if the forwarding call fails.
-
closeOnCompletion
/////////////////////////////////////////////////////////////////- Specified by:
closeOnCompletionin interfaceEngineStatement- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletionin interfaceEngineStatement- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
executeLargeBatch
/////////////////////////////////////////////////////////////////- Specified by:
executeLargeBatchin interfaceEngineStatement- Specified by:
executeLargeBatchin interfaceStatement- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceEngineStatement- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceEngineStatement- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceEngineStatement- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceEngineStatement- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLException
-
getLargeMaxRows
- Specified by:
getLargeMaxRowsin interfaceEngineStatement- Specified by:
getLargeMaxRowsin interfaceStatement- Throws:
SQLException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCountin interfaceEngineStatement- Specified by:
getLargeUpdateCountin interfaceStatement- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRowsin interfaceEngineStatement- Specified by:
setLargeMaxRowsin interfaceStatement- Throws:
SQLException
-