Class SQLServerPreparedStatement
- All Implemented Interfaces:
ISQLServerPreparedStatement
,ISQLServerStatement
,Serializable
,AutoCloseable
,PreparedStatement
,Statement
,Wrapper
- Direct Known Subclasses:
SQLServerCallableStatement
SQLServerPreparedStatement prepares a statement using SQL Server's sp_prepexec and re-uses the returned statement handle for each subsequent execution of the statement (typically using different parameters provided by the user)
SQLServerPreparedStatement supports batching whereby a set of prepared statements are executed in a single database round trip to improve runtime performance.
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
Fields inherited from class com.microsoft.sqlserver.jdbc.SQLServerStatement
stmtColumnEncriptionSetting
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 TypeMethodDescriptionfinal void
addBatch()
void
final void
final void
boolean
execute()
final boolean
int[]
Sends a batch of statements to the database.long[]
long
final ResultSet
executeQuery
(String sql) int
final int
executeUpdate
(String sql) final ResultSetMetaData
final ParameterMetaData
final ParameterMetaData
getParameterMetaData
(boolean forceRefresh) Returns parameter metadata for the prepared statement.int
The server handle for this prepared statement.final boolean
Returns the current flag value for useFmtOnly.final void
final void
setAsciiStream
(int parameterIndex, InputStream x) final void
setAsciiStream
(int n, InputStream x, int length) final void
setAsciiStream
(int parameterIndex, InputStream x, long length) final void
setBigDecimal
(int parameterIndex, BigDecimal x) final void
setBigDecimal
(int parameterIndex, BigDecimal x, int precision, int scale) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
setBigDecimal
(int parameterIndex, BigDecimal x, int precision, int scale, boolean forceEncrypt) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
setBinaryStream
(int parameterIndex, InputStream x) final void
setBinaryStream
(int n, InputStream x, int length) final void
setBinaryStream
(int parameterIndex, InputStream x, long length) final void
setBlob
(int parameterIndex, InputStream inputStream) final void
setBlob
(int parameterIndex, InputStream inputStream, long length) final void
final void
setBoolean
(int n, boolean x) final void
setBoolean
(int n, boolean x, boolean forceEncrypt) Sets the designated parameter to the given Javaboolean
value.final void
setByte
(int n, byte x) final void
setByte
(int n, byte x, boolean forceEncrypt) Sets the designated parameter to the given Javabyte
value.final void
setBytes
(int n, byte[] x) final void
setBytes
(int n, byte[] x, boolean forceEncrypt) Sets the designated parameter to the given Java array of bytes.final void
setCharacterStream
(int parameterIndex, Reader reader) final void
setCharacterStream
(int n, Reader reader, int length) final void
setCharacterStream
(int parameterIndex, Reader reader, long length) final void
final void
final void
final void
final void
final void
Sets the designated parameter to the givenjava.sql.Date
value, using the givenCalendar
object.final void
setDateTime
(int n, Timestamp x) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setDateTime
(int n, Timestamp x, boolean forceEncrypt) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setDateTimeOffset
(int n, DateTimeOffset x) Sets the designated parameter to the givenmicrosoft.sql.DateTimeOffset
value.final void
setDateTimeOffset
(int n, DateTimeOffset x, int scale) Sets the designated parameter to the givenmicrosoft.sql.DatetimeOffset
value.final void
setDateTimeOffset
(int n, DateTimeOffset x, int scale, boolean forceEncrypt) Sets the designated parameter to the givenmicrosoft.sql.DatetimeOffset
value.final void
setDouble
(int n, double x) final void
setDouble
(int n, double x, boolean forceEncrypt) Sets the designated parameter to the given Javadouble
value.final void
setFloat
(int n, float x) final void
setFloat
(int n, float x, boolean forceEncrypt) Sets the designated parameter to the given Javafloat
value.final void
setGeography
(int n, Geography x) Sets the designated parameter to the givenmicrosoft.sql.Geography
Class object.final void
setGeometry
(int n, Geometry x) Sets the designated parameter to the givenmicrosoft.sql.Geometry
Class object.final void
setInt
(int n, int value) final void
setInt
(int n, int value, boolean forceEncrypt) Sets the designated parameter to the given Javaint
value.final void
setLong
(int n, long x) final void
setLong
(int n, long x, boolean forceEncrypt) Sets the designated parameter to the given Javalong
value.final void
setMoney
(int n, BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
setMoney
(int n, BigDecimal x, boolean forceEncrypt) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
setNCharacterStream
(int parameterIndex, Reader value) final void
setNCharacterStream
(int parameterIndex, Reader value, long length) final void
final void
final void
final void
setNString
(int parameterIndex, String value) final void
setNString
(int parameterIndex, String value, boolean forceEncrypt) Sets the designated parameter to the givenString
object.final void
setNull
(int index, int jdbcType) final void
final void
final void
final void
final void
Sets the value of the designated parameter with the given object.final void
setObject
(int parameterIndex, Object x, int targetSqlType, Integer precision, int scale, boolean forceEncrypt) Sets the value of the designated parameter with the given object.final void
final void
final void
Sets the value of the designated parameter with the given object.final void
setObject
(int parameterIndex, Object x, SQLType targetSqlType, Integer precision, Integer scale, boolean forceEncrypt) Sets the value of the designated parameter with the given object.final void
final void
final void
setShort
(int index, short x) final void
setShort
(int index, short x, boolean forceEncrypt) Sets the designated parameter to the given Javashort
value.final void
setSmallDateTime
(int n, Timestamp x) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setSmallDateTime
(int n, Timestamp x, boolean forceEncrypt) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setSmallMoney
(int n, BigDecimal x) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
setSmallMoney
(int n, BigDecimal x, boolean forceEncrypt) Sets the designated parameter to the givenjava.math.BigDecimal
value.final void
final void
final void
Sets the designated parameter to the given JavaString
value.final void
setStructured
(int n, String tvpName, ISQLServerDataRecord tvpBulkRecord) Sets the server bulk record to populate a table valued parameter.final void
setStructured
(int n, String tvpName, SQLServerDataTable tvpDataTable) Sets the data table to populates a table valued parameter.final void
setStructured
(int n, String tvpName, ResultSet tvpResultSet) Sets the result set to populate a table-valued parameter.final void
final void
Sets the designated parameter to the givenjava.sql.Time
value.final void
Sets the designated parameter to the givenjava.sql.Time
value.final void
final void
Sets the designated parameter to the givenjava.sql.Time
value.final void
setTimestamp
(int n, Timestamp x) final void
setTimestamp
(int n, Timestamp x, int scale) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setTimestamp
(int n, Timestamp x, int scale, boolean forceEncrypt) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setTimestamp
(int n, Timestamp x, Calendar cal) final void
setTimestamp
(int n, Timestamp x, Calendar cal, boolean forceEncrypt) Sets the designated parameter to the givenjava.sql.Timestamp
value.final void
setUnicodeStream
(int n, InputStream x, int length) Deprecated.final void
setUniqueIdentifier
(int index, String guid) Sets the designated parameter to the given String.final void
setUniqueIdentifier
(int index, String guid, boolean forceEncrypt) Sets the designated parameter to the given String.final void
final void
setUseFmtOnly
(boolean useFmtOnly) Specifies the flag to use FMTONLY for parameter metadata queries.Methods inherited from class com.microsoft.sqlserver.jdbc.SQLServerStatement
cancel, clearWarnings, close, closeOnCompletion, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, executeUpdate, getCancelQueryTimeout, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResponseBuffering, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getStmtColumnEncriptionSetting, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isWrapperFor, registerColumnEncryptionKeyStoreProvidersOnStatement, setCancelQueryTimeout, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout, setResponseBuffering, toString, unwrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.microsoft.sqlserver.jdbc.ISQLServerStatement
getCancelQueryTimeout, getResponseBuffering, setCancelQueryTimeout, setResponseBuffering
Methods inherited from interface java.sql.Statement
cancel, clearWarnings, close, closeOnCompletion, enquoteIdentifier, enquoteLiteral, enquoteNCharLiteral, execute, execute, execute, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeLargeUpdate, executeUpdate, executeUpdate, executeUpdate, getConnection, getFetchDirection, getFetchSize, getGeneratedKeys, getLargeMaxRows, getLargeUpdateCount, getMaxFieldSize, getMaxRows, getMoreResults, getMoreResults, getQueryTimeout, getResultSet, getResultSetConcurrency, getResultSetHoldability, getResultSetType, getUpdateCount, getWarnings, isClosed, isCloseOnCompletion, isPoolable, isSimpleIdentifier, setCursorName, setEscapeProcessing, setFetchDirection, setFetchSize, setLargeMaxRows, setMaxFieldSize, setMaxRows, setPoolable, setQueryTimeout
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Method Details
-
getPreparedStatementHandle
Description copied from interface:ISQLServerPreparedStatement
The server handle for this prepared statement. If a value < 1 is returned no handle has been created.- Specified by:
getPreparedStatementHandle
in interfaceISQLServerPreparedStatement
- Returns:
- Per the description.
- Throws:
SQLServerException
- when an error occurs
-
clearParameters
- Specified by:
clearParameters
in interfacePreparedStatement
- Throws:
SQLServerException
-
executeQuery
- Specified by:
executeQuery
in interfacePreparedStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeUpdate
- Specified by:
executeUpdate
in interfacePreparedStatement
- Throws:
SQLServerException
SQLTimeoutException
-
executeLargeUpdate
- Specified by:
executeLargeUpdate
in interfacePreparedStatement
- Throws:
SQLServerException
SQLTimeoutException
-
execute
- Specified by:
execute
in interfacePreparedStatement
- Throws:
SQLServerException
SQLTimeoutException
-
getMetaData
- Specified by:
getMetaData
in interfacePreparedStatement
- Throws:
SQLServerException
SQLTimeoutException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setAsciiStream
- Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLServerException
-
setAsciiStream
public final void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException - Specified by:
setAsciiStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBigDecimal
- Specified by:
setBigDecimal
in interfacePreparedStatement
- Throws:
SQLServerException
-
setBigDecimal
public final void setBigDecimal(int parameterIndex, BigDecimal x, int precision, int scale) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setBigDecimal
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter valueprecision
- the precision of the columnscale
- the scale of the column- Throws:
SQLServerException
- when an error occurs
-
setBigDecimal
public final void setBigDecimal(int parameterIndex, BigDecimal x, int precision, int scale, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setBigDecimal
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the parameter valueprecision
- the precision of the columnscale
- the scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setMoney
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setMoney
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setMoney
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setMoney
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setSmallMoney
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setSmallMoney
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setSmallMoney
public final void setSmallMoney(int n, BigDecimal x, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.math.BigDecimal
value. The driver converts this to an SQLNUMERIC
value when it sends it to the database.- Specified by:
setSmallMoney
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setBinaryStream
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBinaryStream
- Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLServerException
-
setBinaryStream
public final void setBinaryStream(int parameterIndex, InputStream x, long length) throws SQLException - Specified by:
setBinaryStream
in interfacePreparedStatement
- Throws:
SQLException
-
setBoolean
- Specified by:
setBoolean
in interfacePreparedStatement
- Throws:
SQLServerException
-
setBoolean
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javaboolean
value. The driver converts this to an SQLBIT
orBOOLEAN
value when it sends it to the database.- Specified by:
setBoolean
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setByte
- Specified by:
setByte
in interfacePreparedStatement
- Throws:
SQLServerException
-
setByte
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javabyte
value. The driver converts this to an SQLTINYINT
value when it sends it to the database.- Specified by:
setByte
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setBytes
- Specified by:
setBytes
in interfacePreparedStatement
- Throws:
SQLServerException
-
setBytes
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQLVARBINARY
orLONGVARBINARY
(depending on the argument's size relative to the driver's limits onVARBINARY
values) when it sends it to the database.- Specified by:
setBytes
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setUniqueIdentifier
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given String. The driver converts this to an SQLGUID
- Specified by:
setUniqueIdentifier
in interfaceISQLServerPreparedStatement
- Parameters:
index
- the first parameter is 1, the second is 2, ...guid
- string representation of the uniqueIdentifier value- Throws:
SQLServerException
- when an error occurs
-
setUniqueIdentifier
public final void setUniqueIdentifier(int index, String guid, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given String. The driver converts this to an SQLGUID
- Specified by:
setUniqueIdentifier
in interfaceISQLServerPreparedStatement
- Parameters:
index
- the first parameter is 1, the second is 2, ...guid
- string representation of the uniqueIdentifier valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setDouble
- Specified by:
setDouble
in interfacePreparedStatement
- Throws:
SQLServerException
-
setDouble
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javadouble
value. The driver converts this to an SQLDOUBLE
value when it sends it to the database.- Specified by:
setDouble
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setFloat
- Specified by:
setFloat
in interfacePreparedStatement
- Throws:
SQLServerException
-
setFloat
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javafloat
value. The driver converts this to an SQLREAL
value when it sends it to the database.- Specified by:
setFloat
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setGeometry
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenmicrosoft.sql.Geometry
Class object. The driver converts this to an SQLREAL
value when it sends it to the database.- Specified by:
setGeometry
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setGeography
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenmicrosoft.sql.Geography
Class object. The driver converts this to an SQLREAL
value when it sends it to the database.- Specified by:
setGeography
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setInt
- Specified by:
setInt
in interfacePreparedStatement
- Throws:
SQLServerException
-
setInt
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javaint
value. The driver converts this to an SQLINTEGER
value when it sends it to the database.- Specified by:
setInt
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...value
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setLong
- Specified by:
setLong
in interfacePreparedStatement
- Throws:
SQLServerException
-
setLong
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javalong
value. The driver converts this to an SQLBIGINT
value when it sends it to the database.- Specified by:
setLong
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setNull
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
public final void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) throws SQLServerException - Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
public final void setObject(int parameterIndex, Object x, int targetSqlType, Integer precision, int scale) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the value of the designated parameter with the given object.The given Java object will be converted to the given targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing the interface
SQLData
), the JDBC driver should call the methodSQLData.writeSQL
to write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef
,Blob
,Clob
,NClob
,Struct
,java.net.URL
, orArray
, the driver should pass it to the database as a value of the corresponding SQL type.Note that this method may be used to pass database-specific abstract data types.
- Specified by:
setObject
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the object containing the input parameter valuetargetSqlType
- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.precision
- the precision of the columnscale
- scale of the column- Throws:
SQLServerException
- when an error occurs
-
setObject
public final void setObject(int parameterIndex, Object x, int targetSqlType, Integer precision, int scale, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the value of the designated parameter with the given object.The given Java object will be converted to the given targetSqlType before being sent to the database. If the object has a custom mapping (is of a class implementing the interface
SQLData
), the JDBC driver should call the methodSQLData.writeSQL
to write it to the SQL data stream. If, on the other hand, the object is of a class implementingRef
,Blob
,Clob
,NClob
,Struct
,java.net.URL
, orArray
, the driver should pass it to the database as a value of the corresponding SQL type.Note that this method may be used to pass database-specific abstract data types.
- Specified by:
setObject
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the object containing the input parameter valuetargetSqlType
- the SQL type (as defined in java.sql.Types) to be sent to the database. The scale argument may further qualify this type.precision
- the precision of the columnscale
- scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setObject
- Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
public final void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLServerException - Specified by:
setObject
in interfacePreparedStatement
- Throws:
SQLServerException
-
setObject
public final void setObject(int parameterIndex, Object x, SQLType targetSqlType, Integer precision, Integer scale) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the value of the designated parameter with the given object. This method is similar toPreparedStatement.setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)
, except that it assumes a scale of zero.The default implementation will throw
SQLFeatureNotSupportedException
- Specified by:
setObject
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the object containing the input parameter valuetargetSqlType
- the SQL type to be sent to the databaseprecision
- the precision of the columnscale
- the scale of the column- Throws:
SQLServerException
- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setObject
public final void setObject(int parameterIndex, Object x, SQLType targetSqlType, Integer precision, Integer scale, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the value of the designated parameter with the given object. This method is similar toPreparedStatement.setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)
, except that it assumes a scale of zero.The default implementation will throw
SQLFeatureNotSupportedException
- Specified by:
setObject
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- the first parameter is 1, the second is 2, ...x
- the object containing the input parameter valuetargetSqlType
- the SQL type to be sent to the databaseprecision
- the precision of the columnscale
- the scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setShort
- Specified by:
setShort
in interfacePreparedStatement
- Throws:
SQLServerException
-
setShort
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given Javashort
value. The driver converts this to an SQLSMALLINT
value when it sends it to the database.- Specified by:
setShort
in interfaceISQLServerPreparedStatement
- Parameters:
index
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setString
- Specified by:
setString
in interfacePreparedStatement
- Throws:
SQLServerException
-
setString
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the given JavaString
value. The driver converts this to an SQLVARCHAR
orLONGVARCHAR
value (depending on the argument's size relative to the driver's limits onVARCHAR
values) when it sends it to the database.- Specified by:
setString
in interfaceISQLServerPreparedStatement
- Parameters:
index
- the first parameter is 1, the second is 2, ...str
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setNString
- Specified by:
setNString
in interfacePreparedStatement
- Throws:
SQLException
-
setNString
public final void setNString(int parameterIndex, String value, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenString
object. The driver converts this to a SQLNCHAR
orNVARCHAR
orLONGNVARCHAR
value (depending on the argument's size relative to the driver's limits onNVARCHAR
values) when it sends it to the database.- Specified by:
setNString
in interfaceISQLServerPreparedStatement
- Parameters:
parameterIndex
- of the first parameter is 1, the second is 2, ...value
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setTime
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLServerException
-
setTime
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Time
value.- Specified by:
setTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the column- Throws:
SQLServerException
- when an error occurs
-
setTime
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Time
value.- Specified by:
setTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setTimestamp
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLServerException
-
setTimestamp
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setTimestamp
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the column- Throws:
SQLServerException
- when an error occurs
-
setTimestamp
public final void setTimestamp(int n, Timestamp x, int scale, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setTimestamp
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setDateTimeOffset
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenmicrosoft.sql.DateTimeOffset
value.- Specified by:
setDateTimeOffset
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- if parameterIndex does not correspond to a parameter marker in the SQL statement; if a database access error occurs or this method is called on a closedPreparedStatement
-
setDateTimeOffset
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenmicrosoft.sql.DatetimeOffset
value.- Specified by:
setDateTimeOffset
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the column- Throws:
SQLServerException
- when an error occurs
-
setDateTimeOffset
public final void setDateTimeOffset(int n, DateTimeOffset x, int scale, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenmicrosoft.sql.DatetimeOffset
value.- Specified by:
setDateTimeOffset
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuescale
- the scale of the columnforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setDate
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLServerException
-
setDateTime
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setDateTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setDateTime
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setDateTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setSmallDateTime
Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setSmallDateTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter value- Throws:
SQLServerException
- when an error occurs
-
setSmallDateTime
public final void setSmallDateTime(int n, Timestamp x, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value.- Specified by:
setSmallDateTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valueforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setStructured
public final void setStructured(int n, String tvpName, SQLServerDataTable tvpDataTable) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the data table to populates a table valued parameter.- Specified by:
setStructured
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...tvpName
- the name of the table valued parametertvpDataTable
- the source datatable object- Throws:
SQLServerException
- when an error occurs
-
setStructured
public final void setStructured(int n, String tvpName, ResultSet tvpResultSet) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the result set to populate a table-valued parameter.- Specified by:
setStructured
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...tvpName
- the name of the table valued parametertvpResultSet
- the source resultset object- Throws:
SQLServerException
- when an error occurs
-
setStructured
public final void setStructured(int n, String tvpName, ISQLServerDataRecord tvpBulkRecord) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the server bulk record to populate a table valued parameter.- Specified by:
setStructured
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...tvpName
- the name of the table valued parametertvpBulkRecord
- an ISQLServerDataRecord object- Throws:
SQLServerException
- when an error occurs
-
setUnicodeStream
@Deprecated public final void setUnicodeStream(int n, InputStream x, int length) throws SQLException Deprecated.- Specified by:
setUnicodeStream
in interfacePreparedStatement
- Throws:
SQLException
-
addBatch
- Specified by:
addBatch
in interfacePreparedStatement
- Throws:
SQLServerException
-
clearBatch
- Specified by:
clearBatch
in interfaceStatement
- Overrides:
clearBatch
in classSQLServerStatement
- Throws:
SQLServerException
-
executeBatch
Description copied from class:SQLServerStatement
Sends a batch of statements to the database.- Specified by:
executeBatch
in interfaceStatement
- Overrides:
executeBatch
in classSQLServerStatement
- Throws:
SQLServerException
BatchUpdateException
SQLTimeoutException
-
executeLargeBatch
public long[] executeLargeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException- Specified by:
executeLargeBatch
in interfaceStatement
- Overrides:
executeLargeBatch
in classSQLServerStatement
- Throws:
SQLServerException
BatchUpdateException
SQLTimeoutException
-
setUseFmtOnly
Description copied from interface:ISQLServerPreparedStatement
Specifies the flag to use FMTONLY for parameter metadata queries.- Specified by:
setUseFmtOnly
in interfaceISQLServerPreparedStatement
- Parameters:
useFmtOnly
- boolean value for 'useFmtOnly'.- Throws:
SQLServerException
- when the connection is closed.
-
getUseFmtOnly
Description copied from interface:ISQLServerPreparedStatement
Returns the current flag value for useFmtOnly.- Specified by:
getUseFmtOnly
in interfaceISQLServerPreparedStatement
- Returns:
- 'useFmtOnly' property value.
- Throws:
SQLServerException
- when the connection is closed.
-
setCharacterStream
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setCharacterStream
- Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLServerException
-
setCharacterStream
public final void setCharacterStream(int parameterIndex, Reader reader, long length) throws SQLException - Specified by:
setCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
- Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setNCharacterStream
public final void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException - Specified by:
setNCharacterStream
in interfacePreparedStatement
- Throws:
SQLException
-
setRef
- Specified by:
setRef
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
- Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setBlob
public final void setBlob(int parameterIndex, InputStream inputStream, long length) throws SQLException - Specified by:
setBlob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setClob
- Specified by:
setClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setNClob
- Specified by:
setNClob
in interfacePreparedStatement
- Throws:
SQLException
-
setArray
- Specified by:
setArray
in interfacePreparedStatement
- Throws:
SQLException
-
setDate
- Specified by:
setDate
in interfacePreparedStatement
- Throws:
SQLServerException
-
setDate
public final void setDate(int n, Date x, Calendar cal, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Date
value, using the givenCalendar
object. The driver uses theCalendar
object to construct an SQLDATE
value, which the driver then sends to the database. With aCalendar
object, the driver can calculate the date taking into account a custom timezone. If noCalendar
object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.- Specified by:
setDate
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuecal
- theCalendar
object the driver will use to construct the dateforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setTime
- Specified by:
setTime
in interfacePreparedStatement
- Throws:
SQLServerException
-
setTime
public final void setTime(int n, Time x, Calendar cal, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Time
value. The driver converts this to an SQLTIME
value when it sends it to the database.- Specified by:
setTime
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuecal
- theCalendar
object the driver will use to construct the dateforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setTimestamp
- Specified by:
setTimestamp
in interfacePreparedStatement
- Throws:
SQLServerException
-
setTimestamp
public final void setTimestamp(int n, Timestamp x, Calendar cal, boolean forceEncrypt) throws SQLServerException Description copied from interface:ISQLServerPreparedStatement
Sets the designated parameter to the givenjava.sql.Timestamp
value. The driver converts this to an SQLTIMESTAMP
value when it sends it to the database.- Specified by:
setTimestamp
in interfaceISQLServerPreparedStatement
- Parameters:
n
- the first parameter is 1, the second is 2, ...x
- the parameter valuecal
- theCalendar
object the driver will use to construct the dateforceEncrypt
- If the boolean forceEncrypt is set to true, the query parameter will only be set if the designation column is encrypted and Always Encrypted is enabled on the connection or on the statement. If the boolean forceEncrypt is set to false, the driver will not force encryption on parameters.- Throws:
SQLServerException
- when an error occurs
-
setNull
- Specified by:
setNull
in interfacePreparedStatement
- Throws:
SQLServerException
-
getParameterMetaData
Description copied from interface:ISQLServerPreparedStatement
Returns parameter metadata for the prepared statement.- Specified by:
getParameterMetaData
in interfaceISQLServerPreparedStatement
- Parameters:
forceRefresh
- If true the cache will not be used to retrieve the metadata.- Returns:
- Per the description.
- Throws:
SQLServerException
- when an error occurs
-
getParameterMetaData
- Specified by:
getParameterMetaData
in interfacePreparedStatement
- Throws:
SQLServerException
-
setURL
- Specified by:
setURL
in interfacePreparedStatement
- Throws:
SQLException
-
setRowId
- Specified by:
setRowId
in interfacePreparedStatement
- Throws:
SQLException
-
setSQLXML
- Specified by:
setSQLXML
in interfacePreparedStatement
- Throws:
SQLException
-
executeUpdate
- Specified by:
executeUpdate
in interfaceStatement
- Overrides:
executeUpdate
in classSQLServerStatement
- Throws:
SQLServerException
-
execute
- Specified by:
execute
in interfaceStatement
- Overrides:
execute
in classSQLServerStatement
- Throws:
SQLServerException
-
executeQuery
- Specified by:
executeQuery
in interfaceStatement
- Overrides:
executeQuery
in classSQLServerStatement
- Throws:
SQLServerException
-
addBatch
- Specified by:
addBatch
in interfaceStatement
- Overrides:
addBatch
in classSQLServerStatement
- Throws:
SQLServerException
-