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
FieldsModifier 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 TypeMethodDescriptionvoidfinal voidcancel()voidfinal voidvoidclose()voidbooleanfinal booleanfinal booleanfinal booleanint[]Sends a batch of statements to the database.long[]longexecuteLargeUpdate(String sql) final longexecuteLargeUpdate(String sql, int autoGeneratedKeys) final longexecuteLargeUpdate(String sql, int[] columnIndexes) final longexecuteLargeUpdate(String sql, String[] columnNames) executeQuery(String sql) intexecuteUpdate(String sql) final intexecuteUpdate(String sql, int autoGeneratedKeys) final intexecuteUpdate(String sql, int[] columnIndexes) final intexecuteUpdate(String sql, String[] columnNames) final intReturns thecancelQueryTimeoutproperty set on this SQLServerStatement object.final ConnectionReturns the statement's connection.final intfinal intfinal ResultSetfinal longfinal longfinal intfinal intfinal booleanReturns more results in the TDS stream.final booleangetMoreResults(int mode) final intfinal StringReturns the response buffering mode for this SQLServerStatement object.final ResultSetfinal intfinal intfinal intReturns the statement column encryption encryption settingfinal intfinal SQLWarningbooleanisClosed()booleanbooleanbooleanisWrapperFor(Class<?> iface) voidregisterColumnEncryptionKeyStoreProvidersOnStatement(Map<String, SQLServerColumnEncryptionKeyStoreProvider> clientKeyStoreProviders) Registers statement-level key store providers, replacing all existing providers.final voidsetCancelQueryTimeout(int seconds) Sets thecancelQueryTimeoutproperty on this SQLServerStatement object to cancelqueryTimeoutset onConnectionorStatementlevel.final voidsetCursorName(String name) final voidsetEscapeProcessing(boolean enable) final voidsetFetchDirection(int nDir) final voidsetFetchSize(int rows) final voidsetLargeMaxRows(long max) final voidsetMaxFieldSize(int max) final voidsetMaxRows(int max) voidsetPoolable(boolean poolable) final voidsetQueryTimeout(int seconds) final voidsetResponseBuffering(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> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceStatement- Throws:
SQLServerException
-
closeOnCompletion
- Specified by:
closeOnCompletionin interfaceStatement- Throws:
SQLException
-
executeQuery
- Specified by:
executeQueryin interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeUpdate
- Specified by:
executeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeLargeUpdate
- Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
execute
- Specified by:
executein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
getMaxFieldSize
- Specified by:
getMaxFieldSizein interfaceStatement- Throws:
SQLServerException
-
setMaxFieldSize
- Specified by:
setMaxFieldSizein interfaceStatement- Throws:
SQLServerException
-
getMaxRows
- Specified by:
getMaxRowsin interfaceStatement- Throws:
SQLServerException
-
getLargeMaxRows
- Specified by:
getLargeMaxRowsin interfaceStatement- Throws:
SQLServerException
-
setMaxRows
- Specified by:
setMaxRowsin interfaceStatement- Throws:
SQLServerException
-
setLargeMaxRows
- Specified by:
setLargeMaxRowsin interfaceStatement- Throws:
SQLServerException
-
setEscapeProcessing
- Specified by:
setEscapeProcessingin interfaceStatement- Throws:
SQLServerException
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfaceStatement- Throws:
SQLServerException
-
setQueryTimeout
- Specified by:
setQueryTimeoutin interfaceStatement- Throws:
SQLServerException
-
getCancelQueryTimeout
Description copied from interface:ISQLServerStatementReturns thecancelQueryTimeoutproperty set on this SQLServerStatement object.- Specified by:
getCancelQueryTimeoutin interfaceISQLServerStatement- Returns:
- cancelQueryTimeout Time duration in seconds.
- Throws:
SQLServerException- if any error occurs
-
setCancelQueryTimeout
Description copied from interface:ISQLServerStatementSets thecancelQueryTimeoutproperty on this SQLServerStatement object to cancelqueryTimeoutset onConnectionorStatementlevel.- Specified by:
setCancelQueryTimeoutin interfaceISQLServerStatement- Parameters:
seconds- Time duration in seconds.- Throws:
SQLServerException- if any error occurs
-
cancel
- Specified by:
cancelin interfaceStatement- Throws:
SQLServerException
-
getWarnings
- Specified by:
getWarningsin interfaceStatement- Throws:
SQLServerException
-
clearWarnings
- Specified by:
clearWarningsin interfaceStatement- Throws:
SQLServerException
-
setCursorName
- Specified by:
setCursorNamein interfaceStatement- Throws:
SQLServerException
-
getResultSet
- Specified by:
getResultSetin interfaceStatement- Throws:
SQLServerException
-
getUpdateCount
- Specified by:
getUpdateCountin interfaceStatement- Throws:
SQLServerException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCountin interfaceStatement- Throws:
SQLServerException
-
getMoreResults
Returns more results in the TDS stream.- Specified by:
getMoreResultsin 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:
setFetchDirectionin interfaceStatement- Throws:
SQLServerException
-
getFetchDirection
- Specified by:
getFetchDirectionin interfaceStatement- Throws:
SQLServerException
-
setFetchSize
- Specified by:
setFetchSizein interfaceStatement- Throws:
SQLServerException
-
getFetchSize
- Specified by:
getFetchSizein interfaceStatement- Throws:
SQLServerException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrencyin interfaceStatement- Throws:
SQLServerException
-
getResultSetType
- Specified by:
getResultSetTypein interfaceStatement- Throws:
SQLServerException
-
addBatch
- Specified by:
addBatchin interfaceStatement- Throws:
SQLServerException
-
clearBatch
- Specified by:
clearBatchin interfaceStatement- Throws:
SQLServerException
-
executeBatch
Sends a batch of statements to the database.- Specified by:
executeBatchin interfaceStatement- Throws:
SQLServerExceptionBatchUpdateExceptionSQLTimeoutException
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException- Specified by:
executeLargeBatchin interfaceStatement- Throws:
SQLServerExceptionBatchUpdateExceptionSQLTimeoutException
-
getConnection
Returns the statement's connection.- Specified by:
getConnectionin interfaceStatement- Returns:
- the connection
- Throws:
SQLServerException- when an error occurs
-
getResultSetHoldability
- Specified by:
getResultSetHoldabilityin interfaceStatement- Throws:
SQLException
-
execute
public final boolean execute(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
executein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
execute
public final boolean execute(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
executein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
execute
public final boolean execute(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
executein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeUpdate
public final int executeUpdate(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
executeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(String sql, String[] columnNames) throws SQLServerException, SQLTimeoutException - Specified by:
executeLargeUpdatein interfaceStatement- Throws:
SQLServerExceptionSQLTimeoutException
-
getGeneratedKeys
- Specified by:
getGeneratedKeysin interfaceStatement- Throws:
SQLServerException
-
getMoreResults
- Specified by:
getMoreResultsin interfaceStatement- Throws:
SQLException
-
isClosed
- Specified by:
isClosedin interfaceStatement- Throws:
SQLException
-
isCloseOnCompletion
- Specified by:
isCloseOnCompletionin interfaceStatement- Throws:
SQLException
-
isPoolable
- Specified by:
isPoolablein interfaceStatement- Throws:
SQLException
-
setPoolable
- Specified by:
setPoolablein interfaceStatement- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
setResponseBuffering
Description copied from interface:ISQLServerStatementSets 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:
setResponseBufferingin 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:ISQLServerStatementReturns the response buffering mode for this SQLServerStatement object.- Specified by:
getResponseBufferingin 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
-