Class BrokeredStatement
- All Implemented Interfaces:
AutoCloseable
,Statement
,Wrapper
,EngineStatement
- Direct Known Subclasses:
BrokeredPreparedStatement
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final BrokeredStatementControl
My control.private String
My stateprivate Boolean
(package private) final int
(package private) final int
(package private) final int
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
final void
cancel()
protected final void
Checks if the statement is closed and throws an exception if it is.final void
final void
After this call getWarnings returns null until a new warning is reported for this Statement.void
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.void
(package private) final BrokeredStatementControl
Get the BrokeredStatementControl in order to perform a check.createDuplicateStatement
(Connection conn, Statement oldStatement) final boolean
final boolean
final boolean
final boolean
final int[]
long[]
long
executeLargeUpdate
(String sql) long
executeLargeUpdate
(String sql, int autoGeneratedKeys) long
executeLargeUpdate
(String sql, int[] columnIndexes) long
executeLargeUpdate
(String sql, String[] columnNames) final ResultSet
executeQuery
(String sql) final int
executeUpdate
(String sql) final int
executeUpdate
(String sql, int autoGeneratedKeys) final int
executeUpdate
(String sql, int[] columnIndexes) final int
executeUpdate
(String sql, String[] columnNames) final Connection
final int
final int
final ResultSet
JDBC 3.0 Retrieves any auto-generated keys created as a result of executing this Statement object.long
long
final int
final int
final boolean
getMoreResults moves to a Statement's next result.final boolean
getMoreResults
(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 int
final ResultSet
getResultSet returns the current result as a ResultSet.final int
final int
Return the holdability of ResultSets created by this Statement.final int
JDBC 2.0 Determine the result set type.final int
getUpdateCount returns the current result as an update count; if the result is a ResultSet or there are no more results -1 is returned.final SQLWarning
The first warning reported by calls on this Statement is returned.final boolean
isClosed()
Checks if the statement is closed.boolean
final boolean
Forwards to the real Statement.boolean
isWrapperFor
(Class iface) Returns false unlessiface
is implementedfinal void
setCursorName
(String name) setCursorName defines the SQL cursor name that will be used by subsequent Statement execute methods.final void
setEscapeProcessing
(boolean enable) If escape scanning is on (the default) the driver will do escape substitution before sending the SQL to the database.final void
setFetchDirection
(int direction) JDBC 2.0 Give a hint as to the direction in which the rows in a result set will be processed.final void
setFetchSize
(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.void
setLargeMaxRows
(long max) final void
setMaxFieldSize
(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 void
setMaxRows
(int max) The maxRows limit is set to limit the number of rows that any ResultSet can contain.final void
setPoolable
(boolean poolable) Forwards to the real Statement.final void
setQueryTimeout
(int seconds) (package private) void
setStatementState
(Statement oldStatement, Statement newStatement) (package private) final SQLException
unableToUnwrap
(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> T
Returnsthis
if this class implements the specified interface.(package private) final ResultSet
Provide the control access to every ResultSet we return.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.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:
addBatch
in interfaceStatement
- Throws:
SQLException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLException
-
executeBatch
- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLException
-
cancel
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLException
- thrown on failure.
-
getConnection
- Specified by:
getConnection
in interfaceStatement
- Throws:
SQLException
-
getFetchDirection
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLException
-
getFetchSize
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLException
-
getMaxFieldSize
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLException
-
getMaxRows
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrency
in 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:
setMaxFieldSize
in 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:
setMaxRows
in 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:
setEscapeProcessing
in 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:
getWarnings
in 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:
clearWarnings
in 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:
setCursorName
in 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:
getResultSet
in 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:
getUpdateCount
in 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:
getMoreResults
in 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:
getResultSetType
in 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:
setFetchDirection
in 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:
setFetchSize
in 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:
getQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
setQueryTimeout
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in 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:
getMoreResults
in 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:
getGeneratedKeys
in 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:
getResultSetHoldability
in 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 unlessiface
is implemented- Specified by:
isWrapperFor
in 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
Returnsthis
if this class implements the specified interface.- Specified by:
unwrap
in 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:
isClosed
in interfaceStatement
- Returns:
true
if the statement is closed,false
otherwise- 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:
isPoolable
in 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:
setPoolable
in interfaceStatement
- Parameters:
poolable
- the new value for the poolable hint.- Throws:
SQLException
- if the forwarding call fails.
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceEngineStatement
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceEngineStatement
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
executeLargeBatch
- Specified by:
executeLargeBatch
in interfaceEngineStatement
- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceEngineStatement
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLException
-
getLargeMaxRows
- Specified by:
getLargeMaxRows
in interfaceEngineStatement
- Specified by:
getLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCount
in interfaceEngineStatement
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLException
-
setLargeMaxRows
- Specified by:
setLargeMaxRows
in interfaceEngineStatement
- Specified by:
setLargeMaxRows
in interfaceStatement
- Throws:
SQLException
-