Package com.microsoft.sqlserver.jdbc
Class SQLServerStatement
java.lang.Object
com.microsoft.sqlserver.jdbc.SQLServerStatement
- All Implemented Interfaces:
ISQLServerStatement,java.io.Serializable,java.lang.AutoCloseable,java.sql.Statement,java.sql.Wrapper
- Direct Known Subclasses:
SQLServerPreparedStatement
public class SQLServerStatement extends java.lang.Object implements ISQLServerStatement
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:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected SQLServerStatementColumnEncryptionSettingstmtColumnEncriptionSetting -
Method Summary
Modifier and Type Method Description voidaddBatch(java.lang.String sql)voidcancel()voidclearBatch()voidclearWarnings()voidclose()voidcloseOnCompletion()booleanexecute(java.lang.String sql)booleanexecute(java.lang.String sql, int autoGeneratedKeys)booleanexecute(java.lang.String sql, int[] columnIndexes)booleanexecute(java.lang.String sql, java.lang.String[] columnNames)int[]executeBatch()Sends a batch of statements to the database.long[]executeLargeBatch()longexecuteLargeUpdate(java.lang.String sql)longexecuteLargeUpdate(java.lang.String sql, int autoGeneratedKeys)longexecuteLargeUpdate(java.lang.String sql, int[] columnIndexes)longexecuteLargeUpdate(java.lang.String sql, java.lang.String[] columnNames)java.sql.ResultSetexecuteQuery(java.lang.String sql)intexecuteUpdate(java.lang.String sql)intexecuteUpdate(java.lang.String sql, int autoGeneratedKeys)intexecuteUpdate(java.lang.String sql, int[] columnIndexes)intexecuteUpdate(java.lang.String sql, java.lang.String[] columnNames)intgetCancelQueryTimeout()Returns thecancelQueryTimeoutproperty set on this SQLServerStatement object.java.sql.ConnectiongetConnection()Returns the statement's connection.intgetFetchDirection()intgetFetchSize()java.sql.ResultSetgetGeneratedKeys()longgetLargeMaxRows()longgetLargeUpdateCount()intgetMaxFieldSize()intgetMaxRows()booleangetMoreResults()Returns more results in the TDS stream.booleangetMoreResults(int mode)intgetQueryTimeout()java.lang.StringgetResponseBuffering()Returns the response buffering mode for this SQLServerStatement object.java.sql.ResultSetgetResultSet()intgetResultSetConcurrency()intgetResultSetHoldability()intgetResultSetType()protected SQLServerStatementColumnEncryptionSettinggetStmtColumnEncriptionSetting()intgetUpdateCount()java.sql.SQLWarninggetWarnings()booleanisClosed()booleanisCloseOnCompletion()booleanisPoolable()booleanisWrapperFor(java.lang.Class<?> iface)voidsetCancelQueryTimeout(int seconds)Sets thecancelQueryTimeoutproperty on this SQLServerStatement object to cancelqueryTimeoutset onConnectionorStatementlevel.voidsetCursorName(java.lang.String name)voidsetEscapeProcessing(boolean enable)voidsetFetchDirection(int nDir)voidsetFetchSize(int rows)voidsetLargeMaxRows(long max)voidsetMaxFieldSize(int max)voidsetMaxRows(int max)voidsetPoolable(boolean poolable)voidsetQueryTimeout(int seconds)voidsetResponseBuffering(java.lang.String value)Sets the response buffering mode for this SQLServerStatement object to case-insensitive String full or adaptive.java.lang.StringtoString()Returns the statement's id for logging info<T> Tunwrap(java.lang.Class<T> iface)
-
Field Details
-
Method Details
-
getStmtColumnEncriptionSetting
-
toString
public java.lang.String toString()Returns the statement's id for logging info- Overrides:
toStringin classjava.lang.Object
-
close
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.sql.Statement- Throws:
SQLServerException
-
closeOnCompletion
public void closeOnCompletion() throws java.sql.SQLException- Specified by:
closeOnCompletionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
executeQuery
public java.sql.ResultSet executeQuery(java.lang.String sql) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeQueryin interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeUpdate
public int executeUpdate(java.lang.String sql) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeLargeUpdate
public long executeLargeUpdate(java.lang.String sql) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
execute
public boolean execute(java.lang.String sql) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
getMaxFieldSize
- Specified by:
getMaxFieldSizein interfacejava.sql.Statement- Throws:
SQLServerException
-
setMaxFieldSize
- Specified by:
setMaxFieldSizein interfacejava.sql.Statement- Throws:
SQLServerException
-
getMaxRows
- Specified by:
getMaxRowsin interfacejava.sql.Statement- Throws:
SQLServerException
-
getLargeMaxRows
- Specified by:
getLargeMaxRowsin interfacejava.sql.Statement- Throws:
SQLServerException
-
setMaxRows
- Specified by:
setMaxRowsin interfacejava.sql.Statement- Throws:
SQLServerException
-
setLargeMaxRows
- Specified by:
setLargeMaxRowsin interfacejava.sql.Statement- Throws:
SQLServerException
-
setEscapeProcessing
- Specified by:
setEscapeProcessingin interfacejava.sql.Statement- Throws:
SQLServerException
-
getQueryTimeout
- Specified by:
getQueryTimeoutin interfacejava.sql.Statement- Throws:
SQLServerException
-
setQueryTimeout
- Specified by:
setQueryTimeoutin interfacejava.sql.Statement- 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 interfacejava.sql.Statement- Throws:
SQLServerException
-
getWarnings
- Specified by:
getWarningsin interfacejava.sql.Statement- Throws:
SQLServerException
-
clearWarnings
- Specified by:
clearWarningsin interfacejava.sql.Statement- Throws:
SQLServerException
-
setCursorName
- Specified by:
setCursorNamein interfacejava.sql.Statement- Throws:
SQLServerException
-
getResultSet
- Specified by:
getResultSetin interfacejava.sql.Statement- Throws:
SQLServerException
-
getUpdateCount
- Specified by:
getUpdateCountin interfacejava.sql.Statement- Throws:
SQLServerException
-
getLargeUpdateCount
- Specified by:
getLargeUpdateCountin interfacejava.sql.Statement- Throws:
SQLServerException
-
getMoreResults
Returns more results in the TDS stream.- Specified by:
getMoreResultsin interfacejava.sql.Statement- 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 interfacejava.sql.Statement- Throws:
SQLServerException
-
getFetchDirection
- Specified by:
getFetchDirectionin interfacejava.sql.Statement- Throws:
SQLServerException
-
setFetchSize
- Specified by:
setFetchSizein interfacejava.sql.Statement- Throws:
SQLServerException
-
getFetchSize
- Specified by:
getFetchSizein interfacejava.sql.Statement- Throws:
SQLServerException
-
getResultSetConcurrency
- Specified by:
getResultSetConcurrencyin interfacejava.sql.Statement- Throws:
SQLServerException
-
getResultSetType
- Specified by:
getResultSetTypein interfacejava.sql.Statement- Throws:
SQLServerException
-
addBatch
- Specified by:
addBatchin interfacejava.sql.Statement- Throws:
SQLServerException
-
clearBatch
- Specified by:
clearBatchin interfacejava.sql.Statement- Throws:
SQLServerException
-
executeBatch
public int[] executeBatch() throws SQLServerException, java.sql.BatchUpdateException, java.sql.SQLTimeoutExceptionSends a batch of statements to the database.- Specified by:
executeBatchin interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.BatchUpdateExceptionjava.sql.SQLTimeoutException
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLServerException, java.sql.BatchUpdateException, java.sql.SQLTimeoutException- Specified by:
executeLargeBatchin interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.BatchUpdateExceptionjava.sql.SQLTimeoutException
-
getConnection
Returns the statement's connection.- Specified by:
getConnectionin interfacejava.sql.Statement- Returns:
- the connection
- Throws:
SQLServerException- when an error occurs
-
getResultSetHoldability
public final int getResultSetHoldability() throws java.sql.SQLException- Specified by:
getResultSetHoldabilityin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
execute
public final boolean execute(java.lang.String sql, int autoGeneratedKeys) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
execute
public final boolean execute(java.lang.String sql, int[] columnIndexes) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
execute
public final boolean execute(java.lang.String sql, java.lang.String[] columnNames) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeUpdate
public final int executeUpdate(java.lang.String sql, int autoGeneratedKeys) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(java.lang.String sql, int autoGeneratedKeys) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeUpdate
public final int executeUpdate(java.lang.String sql, int[] columnIndexes) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(java.lang.String sql, int[] columnIndexes) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeUpdate
public final int executeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
executeLargeUpdate
public final long executeLargeUpdate(java.lang.String sql, java.lang.String[] columnNames) throws SQLServerException, java.sql.SQLTimeoutException- Specified by:
executeLargeUpdatein interfacejava.sql.Statement- Throws:
SQLServerExceptionjava.sql.SQLTimeoutException
-
getGeneratedKeys
- Specified by:
getGeneratedKeysin interfacejava.sql.Statement- Throws:
SQLServerException
-
getMoreResults
public final boolean getMoreResults(int mode) throws java.sql.SQLException- Specified by:
getMoreResultsin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
isClosed
public boolean isClosed() throws java.sql.SQLException- Specified by:
isClosedin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
isCloseOnCompletion
public boolean isCloseOnCompletion() throws java.sql.SQLException- Specified by:
isCloseOnCompletionin interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
isPoolable
public boolean isPoolable() throws java.sql.SQLException- Specified by:
isPoolablein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
setPoolable
public void setPoolable(boolean poolable) throws java.sql.SQLException- Specified by:
setPoolablein interfacejava.sql.Statement- Throws:
java.sql.SQLException
-
isWrapperFor
public boolean isWrapperFor(java.lang.Class<?> iface) throws java.sql.SQLException- Specified by:
isWrapperForin interfacejava.sql.Wrapper- Throws:
java.sql.SQLException
-
unwrap
public <T> T unwrap(java.lang.Class<T> iface) throws java.sql.SQLException- Specified by:
unwrapin interfacejava.sql.Wrapper- Throws:
java.sql.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.
-