Package com.microsoft.sqlserver.jdbc
Class SQLServerStatement
java.lang.Object
com.microsoft.sqlserver.jdbc.SQLServerStatement
- All Implemented Interfaces:
ISQLServerStatement
,Serializable
,AutoCloseable
,Statement
,Wrapper
- Direct Known Subclasses:
SQLServerPreparedStatement
Provides an implementation of java.sql.Statement JDBC Interface to assist in creating Statements against SQL Server.
It also provides a number of base class implementation methods for the JDBC prepared statement and callable
Statements. SQLServerStatement's basic role is to execute SQL statements and return update counts and resultset rows
to the user application.
Documentation for specific public methods that are undocumented can be found under Sun's standard JDBC documentation
for class java.sql.Statement. Those methods are part of Sun's standard JDBC documentation and therefore their
documentation is not duplicated here.
Implementation Notes
Fetching Result sets
The queries first rowset is available immediately after the executeQuery. The first rs.next() does not make a server round trip. For non server side resultsets the entire result set is in the rowset. For server side result sets the number of rows in the rowset is set with nFetchSize
The API javadoc for JDBC API methods that this class implements are not repeated here. Please see Sun's JDBC API interfaces javadoc for those details.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionColumn Encryption Override.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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
final void
cancel()
void
final void
void
close()
void
boolean
final boolean
final boolean
final boolean
int[]
Sends a batch of statements to the database.long[]
long
executeLargeUpdate
(String sql) final long
executeLargeUpdate
(String sql, int autoGeneratedKeys) final long
executeLargeUpdate
(String sql, int[] columnIndexes) final long
executeLargeUpdate
(String sql, String[] columnNames) executeQuery
(String sql) 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 int
Returns thecancelQueryTimeout
property set on this SQLServerStatement object.final Connection
Returns the statement's connection.final int
final int
final ResultSet
final long
final long
final int
final int
final boolean
Returns more results in the TDS stream.final boolean
getMoreResults
(int mode) final int
final String
Returns the response buffering mode for this SQLServerStatement object.final ResultSet
final int
final int
final int
Returns the statement column encryption encryption settingfinal int
final SQLWarning
boolean
isClosed()
boolean
boolean
boolean
isWrapperFor
(Class<?> iface) void
registerColumnEncryptionKeyStoreProvidersOnStatement
(Map<String, SQLServerColumnEncryptionKeyStoreProvider> clientKeyStoreProviders) Registers statement-level key store providers, replacing all existing providers.final void
setCancelQueryTimeout
(int seconds) Sets thecancelQueryTimeout
property on this SQLServerStatement object to cancelqueryTimeout
set onConnection
orStatement
level.final void
setCursorName
(String name) final void
setEscapeProcessing
(boolean enable) final void
setFetchDirection
(int nDir) final void
setFetchSize
(int rows) final void
setLargeMaxRows
(long max) final void
setMaxFieldSize
(int max) final void
setMaxRows
(int max) void
setPoolable
(boolean poolable) final void
setQueryTimeout
(int seconds) final void
setResponseBuffering
(String value) Sets the response buffering mode for this SQLServerStatement object to case-insensitive String full or adaptive.toString()
Returns the statement's id for logging info<T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.sql.Statement
enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, isSimpleIdentifier
-
Field Details
-
stmtColumnEncriptionSetting
Column Encryption Override. Defaults to the connection setting, in which case it will be Enabled if columnEncryptionSetting = true in the connection setting, Disabled if false. This may also be used to set other behavior which overrides connection level setting.
-
-
Method Details
-
getStmtColumnEncriptionSetting
Returns the statement column encryption encryption setting- Returns:
- stmtColumnEncriptionSetting
-
toString
Returns the statement's id for logging info -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceStatement
- Throws:
SQLServerException
-
closeOnCompletion
- Specified by:
closeOnCompletion
in interfaceStatement
- Throws:
SQLException
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
execute
- Specified by:
execute
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
getMaxFieldSize
- Specified by:
getMaxFieldSize
in interfaceStatement
- Throws:
SQLServerException
-
setMaxFieldSize
- Specified by:
setMaxFieldSize
in interfaceStatement
- Throws:
SQLServerException
-
getMaxRows
- Specified by:
getMaxRows
in interfaceStatement
- Throws:
SQLServerException
-
getLargeMaxRows
- Specified by:
getLargeMaxRows
in interfaceStatement
- Throws:
SQLServerException
-
setMaxRows
- Specified by:
setMaxRows
in interfaceStatement
- Throws:
SQLServerException
-
setLargeMaxRows
- Specified by:
setLargeMaxRows
in interfaceStatement
- Throws:
SQLServerException
-
setEscapeProcessing
- Specified by:
setEscapeProcessing
in interfaceStatement
- Throws:
SQLServerException
-
getQueryTimeout
- Specified by:
getQueryTimeout
in interfaceStatement
- Throws:
SQLServerException
-
setQueryTimeout
- Specified by:
setQueryTimeout
in interfaceStatement
- Throws:
SQLServerException
-
getCancelQueryTimeout
Description copied from interface:ISQLServerStatement
Returns thecancelQueryTimeout
property set on this SQLServerStatement object.- Specified by:
getCancelQueryTimeout
in interfaceISQLServerStatement
- Returns:
- cancelQueryTimeout Time duration in seconds.
- Throws:
SQLServerException
- if any error occurs
-
setCancelQueryTimeout
Description copied from interface:ISQLServerStatement
Sets thecancelQueryTimeout
property on this SQLServerStatement object to cancelqueryTimeout
set onConnection
orStatement
level.- Specified by:
setCancelQueryTimeout
in interfaceISQLServerStatement
- Parameters:
seconds
- Time duration in seconds.- Throws:
SQLServerException
- if any error occurs
-
cancel
- Specified by:
cancel
in interfaceStatement
- Throws:
SQLServerException
-
getWarnings
- Specified by:
getWarnings
in interfaceStatement
- Throws:
SQLServerException
-
clearWarnings
- Specified by:
clearWarnings
in interfaceStatement
- Throws:
SQLServerException
-
setCursorName
- Specified by:
setCursorName
in interfaceStatement
- Throws:
SQLServerException
-
getResultSet
- Specified by:
getResultSet
in interfaceStatement
- Throws:
SQLServerException
-
getUpdateCount
- Specified by:
getUpdateCount
in interfaceStatement
- Throws:
SQLServerException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCount
in interfaceStatement
- Throws:
SQLServerException
-
getMoreResults
Returns more results in the TDS stream.- Specified by:
getMoreResults
in interfaceStatement
- Returns:
- true if the next result is a ResultSet object; false if it is an integer (indicating that it is an update count or there are no more results).
- Throws:
SQLServerException
-
setFetchDirection
- Specified by:
setFetchDirection
in interfaceStatement
- Throws:
SQLServerException
-
getFetchDirection
- Specified by:
getFetchDirection
in interfaceStatement
- Throws:
SQLServerException
-
setFetchSize
- Specified by:
setFetchSize
in interfaceStatement
- Throws:
SQLServerException
-
getFetchSize
- Specified by:
getFetchSize
in interfaceStatement
- Throws:
SQLServerException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrency
in interfaceStatement
- Throws:
SQLServerException
-
getResultSetType
- Specified by:
getResultSetType
in interfaceStatement
- Throws:
SQLServerException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Throws:
SQLServerException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Throws:
SQLServerException
-
executeBatch
Sends a batch of statements to the database.- Specified by:
executeBatch
in interfaceStatement
- Throws:
SQLServerException
BatchUpdateException
SQLTimeoutException
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException- Specified by:
executeLargeBatch
in interfaceStatement
- Throws:
SQLServerException
BatchUpdateException
SQLTimeoutException
-
getConnection
Returns the statement's connection.- Specified by:
getConnection
in interfaceStatement
- Returns:
- the connection
- Throws:
SQLServerException
- when an error occurs
-
getResultSetHoldability
- Specified by:
getResultSetHoldability
in interfaceStatement
- Throws:
SQLException
-
execute
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
execute
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
execute
public final boolean execute(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
execute
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
execute
public final boolean execute(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
execute
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdate
in interfaceStatement
- Throws:
SQLServerException
SQLTimeoutException
-
getGeneratedKeys
- Specified by:
getGeneratedKeys
in interfaceStatement
- Throws:
SQLServerException
-
getMoreResults
- Specified by:
getMoreResults
in interfaceStatement
- Throws:
SQLException
-
isClosed
- Specified by:
isClosed
in interfaceStatement
- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletion
in interfaceStatement
- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolable
in interfaceStatement
- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolable
in interfaceStatement
- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
setResponseBuffering
Description copied from interface:ISQLServerStatement
Sets the response buffering mode for this SQLServerStatement object to case-insensitive String full or adaptive.Response buffering controls the driver's buffering of responses from SQL Server.
Possible values are:
"full" - Fully buffer the response at execution time.
"adaptive" - Data Pipe adaptive buffering
- Specified by:
setResponseBuffering
in interfaceISQLServerStatement
- Parameters:
value
- A String that contains the response buffering mode. The valid mode can be one of the following case-insensitive Strings: full or adaptive.- Throws:
SQLServerException
- If there are any errors in setting the response buffering mode.
-
getResponseBuffering
Description copied from interface:ISQLServerStatement
Returns the response buffering mode for this SQLServerStatement object.- Specified by:
getResponseBuffering
in interfaceISQLServerStatement
- Returns:
- A String that contains a lower-case full or adaptive.
- Throws:
SQLServerException
- If there are any errors in retrieving the response buffering mode.
-
registerColumnEncryptionKeyStoreProvidersOnStatement
public void registerColumnEncryptionKeyStoreProvidersOnStatement(Map<String, SQLServerColumnEncryptionKeyStoreProvider> clientKeyStoreProviders) throws SQLServerExceptionRegisters statement-level key store providers, replacing all existing providers.- Parameters:
clientKeyStoreProviders
- a map containing the store providers information.- Throws:
SQLServerException
- when an error occurs
-