Class SQLServerPreparedStatement

  • All Implemented Interfaces:
    ISQLServerPreparedStatement, ISQLServerStatement, Serializable, AutoCloseable, PreparedStatement, Statement, Wrapper
    Direct Known Subclasses:
    SQLServerCallableStatement

    public class SQLServerPreparedStatement
    extends SQLServerStatement
    implements ISQLServerPreparedStatement
    Provides an implementation of java.sql.PreparedStatement interface that assists in preparing Statements for SQL Server.

    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:
    Serialized Form
    • Method Detail

      • defineParameterType

        public void defineParameterType​(int parameterIndex,
                                        int sqlType,
                                        int maxLength)
                                 throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Specifies the SQL type and maximum character or byte length for a parameter, allowing the driver to use a tighter type declaration than the default (e.g. varchar(50) instead of varchar(8000)). This enables SQL Server to compute a more accurate memory grant for query execution plans, which is especially beneficial for large batch operations. Important: The sqlType argument identifies the intended type family (character or binary) and is used for two purposes: (1) Validation that the type is one of the supported character or binary types. (2) Type family enforcement at execution time — the setter method invoked on the parameter must produce a type in the same family as the declared sqlType. For example, declaring Types.VARCHAR then calling setBytes() (binary family) will fail with R_defineParameterTypeTypeMismatch. The character family includes VARCHAR, CHAR, NVARCHAR, and NCHAR; the binary family includes VARBINARY and BINARY. The actual wire type (e.g. nvarchar vs varchar) is still determined by the setter method (e.g. setString → NVARCHAR when sendStringParametersAsUnicode=true, setNString → NVARCHAR, setBytes → VARBINARY). Only the maxLength value is retained and applied to the type definition sent to the server. Precedence: If defineParameterType is called on a parameter, its maxLength hint takes precedence over any length specified via setObject(..., scaleOrLength) for that parameter. This allows developers to establish a baseline type contract that is not overridden by subsequent setter calls. The hint persists across addBatch calls on this prepared statement for the specified parameter — call it once before the batch loop. Only character types (VARCHAR, CHAR, NVARCHAR, NCHAR) and binary types (VARBINARY, BINARY) are supported. If a value longer than maxLength is set for supported short character/binary parameter types, execution fails with an error instead of silently truncating the outbound value. For declarations that map to max types (for example, hints beyond short type limits), SQL Server continues to enforce the declared parameter type/length during execution. The caller should set a hint that accommodates their largest expected value. When sendStringParametersAsUnicode is true (the default), VARCHAR/CHAR hints produce a declared parameter type of nvarchar(N) because setString() promotes the parameter to NVARCHAR. When sendStringParametersAsUnicode is false, VARCHAR/CHAR hints produce varchar(N). setNString() always produces nvarchar(N) regardless of the connection property.
        Specified by:
        defineParameterType in interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        sqlType - a java.sql.Types constant indicating the intended type family; used only for validation (must be VARCHAR, CHAR, NVARCHAR, NCHAR, VARBINARY, or BINARY). The actual wire type is determined by the setter method called on the parameter, not by this value.
        maxLength - the expected maximum length in characters (for VARCHAR/CHAR/NVARCHAR/NCHAR) or bytes (for VARBINARY/BINARY); must be > 0
        Throws:
        SQLServerException - if parameterIndex is out of range, maxLength is non-positive, sqlType is not a supported type, this method is called on a closed statement, or execution detects a value length that exceeds maxLength for supported short character/binary parameter types
      • shouldConsumeInsertDoneToken

        protected boolean shouldConsumeInsertDoneToken()
        Decides whether to consume INSERT DONEINPROC tokens on the execute() path (only reached when onDone() matches EXECUTE == executeMethod). Consume when generated keys are requested so the parser reaches the injected SCOPE_IDENTITY() ResultSet (PR #2554 / #2740 / #2742); otherwise do not consume, so every update count in compound SQL (e.g. DELETE; INSERT; INSERT; UPDATE; INSERT; SELECT) and the trailing SELECT are preserved (GitHub #2722 / #2940) — per the documented contract that lastUpdateCount applies only to executeUpdate(), while all other execute methods return all results and update counts (lastUpdateCount). The EXECUTE_UPDATE branch below is defensive only and unreachable today.
        Overrides:
        shouldConsumeInsertDoneToken in class SQLServerStatement
        Returns:
        true to consume INSERT DONEINPROC tokens silently, false to return them as results
      • 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 given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
        Specified by:
        setBigDecimal in interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        x - the parameter value
        precision - the precision of the column
        scale - 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 given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
        Specified by:
        setBigDecimal in interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        x - the parameter value
        precision - the precision of the column
        scale - the scale of the column
        forceEncrypt - 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

        public final void setMoney​(int n,
                                   BigDecimal x,
                                   boolean forceEncrypt)
                            throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
        Specified by:
        setMoney in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setSmallMoney​(int n,
                                        BigDecimal x,
                                        boolean forceEncrypt)
                                 throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given java.math.BigDecimal value. The driver converts this to an SQL NUMERIC value when it sends it to the database.
        Specified by:
        setSmallMoney in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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
      • setBoolean

        public final void setBoolean​(int n,
                                     boolean x,
                                     boolean forceEncrypt)
                              throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java boolean value. The driver converts this to an SQL BIT or BOOLEAN value when it sends it to the database.
        Specified by:
        setBoolean in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setByte​(int n,
                                  byte x,
                                  boolean forceEncrypt)
                           throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java byte value. The driver converts this to an SQL TINYINT value when it sends it to the database.
        Specified by:
        setByte in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setBytes​(int n,
                                   byte[] x,
                                   boolean forceEncrypt)
                            throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.
        Specified by:
        setBytes in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        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 SQL GUID
        Specified by:
        setUniqueIdentifier in interface ISQLServerPreparedStatement
        Parameters:
        index - the first parameter is 1, the second is 2, ...
        guid - string representation of the uniqueIdentifier value
        forceEncrypt - 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

        public final void setDouble​(int n,
                                    double x,
                                    boolean forceEncrypt)
                             throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java double value. The driver converts this to an SQL DOUBLE value when it sends it to the database.
        Specified by:
        setDouble in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setFloat​(int n,
                                   float x,
                                   boolean forceEncrypt)
                            throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java float value. The driver converts this to an SQL REAL value when it sends it to the database.
        Specified by:
        setFloat in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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
      • setInt

        public final void setInt​(int n,
                                 int value,
                                 boolean forceEncrypt)
                          throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java int value. The driver converts this to an SQL INTEGER value when it sends it to the database.
        Specified by:
        setInt in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        value - the parameter value
        forceEncrypt - 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

        public final void setLong​(int n,
                                  long x,
                                  boolean forceEncrypt)
                           throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java long value. The driver converts this to an SQL BIGINT value when it sends it to the database.
        Specified by:
        setLong in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setObject​(int parameterIndex,
                                    Object x,
                                    int targetSqlType,
                                    int scaleOrLength)
                             throws SQLServerException
        For character and binary target types (VARCHAR, CHAR, NVARCHAR, NCHAR, VARBINARY, BINARY), scaleOrLength is interpreted as an advisory length hint that shapes the parameter's declared type definition. It is never enforced: if the actual value is longer than scaleOrLength, the driver widens the declared length to the actual value length instead of failing or truncating. Passing a zero or negative value disables the application-provided hint entirely, and the driver falls back to its default parameter sizing. This keeps the historical behavior of setObject, where scaleOrLength was ignored for string and binary types per the JDBC 4.3 specification, while allowing applications that supply an accurate hint to get a narrower parameter declaration and better plan reuse. Widening changes the parameter's type definition, so it may cause the statement to be re-prepared. Supply a hint large enough for the largest expected value to avoid this. If defineParameterType(int, int, int) has been called for the same parameter, its maxLength takes precedence over scaleOrLength and, unlike this hint, is enforced as a hard maximum.
        Specified by:
        setObject in interface PreparedStatement
        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 method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, NClob, Struct, java.net.URL, or Array, 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 interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        x - the object containing the input parameter value
        targetSqlType - 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 column
        scale - 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 method SQLData.writeSQL to write it to the SQL data stream. If, on the other hand, the object is of a class implementing Ref, Blob, Clob, NClob, Struct, java.net.URL, or Array, 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 interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        x - the object containing the input parameter value
        targetSqlType - 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 column
        scale - scale of the column
        forceEncrypt - 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

        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 to PreparedStatement.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 interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - the first parameter is 1, the second is 2, ...
        x - the object containing the input parameter value
        targetSqlType - the SQL type to be sent to the database
        precision - the precision of the column
        scale - the scale of the column
        forceEncrypt - 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 closed PreparedStatement
      • setShort

        public final void setShort​(int index,
                                   short x,
                                   boolean forceEncrypt)
                            throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java short value. The driver converts this to an SQL SMALLINT value when it sends it to the database.
        Specified by:
        setShort in interface ISQLServerPreparedStatement
        Parameters:
        index - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setString​(int index,
                                    String str,
                                    boolean forceEncrypt)
                             throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given Java String value. The driver converts this to an SQL VARCHAR or LONGVARCHAR value (depending on the argument's size relative to the driver's limits on VARCHAR values) when it sends it to the database.
        Specified by:
        setString in interface ISQLServerPreparedStatement
        Parameters:
        index - the first parameter is 1, the second is 2, ...
        str - the parameter value
        forceEncrypt - 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

        public final void setNString​(int parameterIndex,
                                     String value,
                                     boolean forceEncrypt)
                              throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given String object. The driver converts this to a SQL NCHAR or NVARCHAR or LONGNVARCHAR value (depending on the argument's size relative to the driver's limits on NVARCHAR values) when it sends it to the database.
        Specified by:
        setNString in interface ISQLServerPreparedStatement
        Parameters:
        parameterIndex - of the first parameter is 1, the second is 2, ...
        value - the parameter value
        forceEncrypt - 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

        public final void setTime​(int n,
                                  Time x,
                                  int scale,
                                  boolean forceEncrypt)
                           throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given java.sql.Time value.
        Specified by:
        setTime in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        scale - the scale of the column
        forceEncrypt - 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

        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 given java.sql.Timestamp value.
        Specified by:
        setTimestamp in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        scale - the scale of the column
        forceEncrypt - 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

        public final void setDateTimeOffset​(int n,
                                            DateTimeOffset x)
                                     throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given microsoft.sql.DateTimeOffset value.
        Specified by:
        setDateTimeOffset in interface ISQLServerPreparedStatement
        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 closed PreparedStatement
      • 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 given microsoft.sql.DatetimeOffset value.
        Specified by:
        setDateTimeOffset in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        scale - the scale of the column
        forceEncrypt - 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
      • setDateTime

        public final void setDateTime​(int n,
                                      Timestamp x,
                                      boolean forceEncrypt)
                               throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given java.sql.Timestamp value.
        Specified by:
        setDateTime in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        public final void setSmallDateTime​(int n,
                                           Timestamp x,
                                           boolean forceEncrypt)
                                    throws SQLServerException
        Description copied from interface: ISQLServerPreparedStatement
        Sets the designated parameter to the given java.sql.Timestamp value.
        Specified by:
        setSmallDateTime in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        forceEncrypt - 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

        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 given java.sql.Date value, using the given Calendar object. The driver uses the Calendar object to construct an SQL DATE value, which the driver then sends to the database. With a Calendar object, the driver can calculate the date taking into account a custom timezone. If no Calendar object is specified, the driver uses the default timezone, which is that of the virtual machine running the application.
        Specified by:
        setDate in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        cal - the Calendar object the driver will use to construct the date
        forceEncrypt - 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

        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 given java.sql.Time value. The driver converts this to an SQL TIME value when it sends it to the database.
        Specified by:
        setTime in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        cal - the Calendar object the driver will use to construct the date
        forceEncrypt - 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

        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 given java.sql.Timestamp value. The driver converts this to an SQL TIMESTAMP value when it sends it to the database.
        Specified by:
        setTimestamp in interface ISQLServerPreparedStatement
        Parameters:
        n - the first parameter is 1, the second is 2, ...
        x - the parameter value
        cal - the Calendar object the driver will use to construct the date
        forceEncrypt - 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