ISQLServerConnection Interface
Implements
public interface ISQLServerConnection
extends java.sql.Connection
Provides an interface to the SQLServerConnection and SQLServerConnectionPoolProxy classes.
Field Summary
| Modifier and Type | Field and Description |
|---|---|
| static final int |
TRANSACTION_SNAPSHOT
Transaction types "TRANSACTION_SNAPSHOT corresponds to" "SET TRANSACTION ISOLATION LEVEL SNAPSHOT" |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
| abstract void |
closeUnreferencedPreparedStatementHandles()
Forces the un-prepare requests for any outstanding discarded prepared statements to be executed. |
| abstract java.sql.Statement |
createStatement(int nType, int nConcur, int nHold, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a |
| abstract java.lang.String |
getAccessTokenCallbackClass()
Returns the fully qualified class name of the implementing class for SQLServerAccessTokenCallback. |
| abstract boolean |
getCalcBigDecimalPrecision()
Returns the current flag for calc |
| abstract java.util.UUID |
getClientConnectionId()
Returns the connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed. |
| abstract java.lang.String |
getDatetimeParameterType()
Returns the value of the datetime |
| abstract boolean |
getDelayLoadingLobs()
Returns the current flag value for delay |
| abstract boolean |
getDisableStatementPooling()
Returns the value whether statement pooling is disabled. |
| abstract int |
getDiscardedServerPreparedStatementCount()
Returns the number of currently outstanding prepared statement un-prepare actions. |
| abstract boolean |
getEnablePrepareOnFirstPreparedStatementCall()
Returns the behavior for a specific connection instance. |
| abstract java.lang.String |
getIPAddressPreference()
Gets the name of the preferred type of IP Address. |
| abstract boolean |
getIgnoreOffsetOnDateTimeOffsetConversion()
Returns the current flag value for ignore |
| abstract int |
getMsiTokenCacheTtl()
Deprecated
Time-to-live is no longer supported for the cached Managed Identity tokens.
This method will always return 0 and is for backwards compatibility only. |
| abstract java.lang.String |
getPrepareMethod()
Returns the behavior for a specific connection instance. |
| abstract boolean |
getSendTimeAsDatetime()
Returns the value of the send |
|
abstract
ISQLServer |
getServerMessageHandler()
Get Currently installed message handler on the connection |
| abstract int |
getServerPreparedStatementDiscardThreshold()
Returns the behavior for a specific connection instance. |
| abstract int |
getStatementHandleCacheEntryCount()
Returns the current number of pooled prepared statement handles. |
| abstract int |
getStatementPoolingCacheSize()
Returns the size of the prepared statement cache for this connection. |
| abstract boolean |
getUseBulkCopyForBatchInsert()
Returns the use |
| abstract boolean |
getUseFmtOnly()
Returns the current flag value for use |
| abstract boolean |
getcacheBulkCopyMetadata()
Sets the value for 'cache |
| abstract boolean |
isStatementPoolingEnabled()
Returns whether statement pooling is enabled or not for this connection. |
| abstract java.sql.CallableStatement |
prepareCall(String sql, int nType, int nConcur, int nHold, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a |
| abstract java.sql.PreparedStatement |
prepareStatement(String sql, int flag, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default |
| abstract java.sql.PreparedStatement |
prepareStatement(String sql, int nType, int nConcur, int resultSetHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a |
| abstract java.sql.PreparedStatement |
prepareStatement(String sql, int[] columnIndexes, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default |
| abstract java.sql.PreparedStatement |
prepareStatement(String sql, String[] columnNames, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default |
| abstract void |
setAccessTokenCallbackClass(String accessTokenCallbackClass)
Sets 'access |
| abstract void |
setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision)
Specifies whether to calculate precision from inputted big decimal values. |
| abstract void |
setDatetimeParameterType(String datetimeParameterTypeValue)
Sets the value of the datetime |
| abstract void |
setDelayLoadingLobs(boolean delayLoadingLobs)
Specifies the flag to immediately load LOB objects into memory. |
| abstract void |
setDisableStatementPooling(boolean value)
Sets the value to Disable/enable statement pooling. |
| abstract void |
setEnablePrepareOnFirstPreparedStatementCall(boolean value)
Sets the behavior for a specific connection instance. |
| abstract void |
setIPAddressPreference(String iPAddressPreference)
Sets the name of the preferred type of IP Address. |
| abstract void |
setIgnoreOffsetOnDateTimeOffsetConversion(boolean ignoreOffsetOnDateTimeOffsetConversion)
Specifies the flag to ignore offset when converting DATETIMEOFFSET to Local |
| abstract void |
setMsiTokenCacheTtl(int timeToLive)
Deprecated
Time-to-live is no longer supported for the cached Managed Identity tokens.
Time-to-live is no longer supported for the cached Managed Identity tokens. |
| abstract void |
setPrepareMethod(String prepareMethod)
Sets the behavior for the prepare method. |
| abstract void |
setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue)
Sets the value of the send |
|
abstract
ISQLServer |
setServerMessageHandler(ISQLServerMessageHandler messageHandler)
Set message handler on the connection |
| abstract void |
setServerPreparedStatementDiscardThreshold(int value)
Sets the behavior for a specific connection instance. |
| abstract void |
setStatementPoolingCacheSize(int value)
Sets the size of the prepared statement cache for this connection. |
| abstract void |
setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert)
Specifies the flag for using Bulk Copy API for batch insert operations. |
| abstract void |
setUseFmtOnly(boolean useFmtOnly)
Specifies the flag to use FMTONLY for parameter metadata queries. |
| abstract void |
setcacheBulkCopyMetadata(boolean cacheBulkCopyMetadata)
Returns value of 'cache |
Field Details
TRANSACTION_SNAPSHOT
public static final int TRANSACTION_SNAPSHOT
Transaction types "TRANSACTION_SNAPSHOT corresponds to" "SET TRANSACTION ISOLATION LEVEL SNAPSHOT"
Method Details
closeUnreferencedPreparedStatementHandles
public abstract void closeUnreferencedPreparedStatementHandles()
Forces the un-prepare requests for any outstanding discarded prepared statements to be executed.
createStatement
public abstract Statement createStatement(int nType, int nConcur, int nHold, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.
Parameters:
ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
ResultSet constants: ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLE
ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
Statement object that will generate ResultSet objects with the given
type, concurrency, and holdabilityThrows:
ResultSet constants indicating type, concurrency, and holdability
getAccessTokenCallbackClass
public abstract String getAccessTokenCallbackClass()
Returns the fully qualified class name of the implementing class for SQLServerAccessTokenCallback.
Returns:
getCalcBigDecimalPrecision
public abstract boolean getCalcBigDecimalPrecision()
Returns the current flag for calcBigDecimalPrecision.
Returns:
getClientConnectionId
public abstract UUID getClientConnectionId()
Returns the connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.
Returns:
Throws:
getDatetimeParameterType
public abstract String getDatetimeParameterType()
Returns the value of the datetimeParameterType property.
Returns:
Throws:
getDelayLoadingLobs
public abstract boolean getDelayLoadingLobs()
Returns the current flag value for delayLoadingLobs.
Returns:
getDisableStatementPooling
public abstract boolean getDisableStatementPooling()
Returns the value whether statement pooling is disabled.
Returns:
getDiscardedServerPreparedStatementCount
public abstract int getDiscardedServerPreparedStatementCount()
Returns the number of currently outstanding prepared statement un-prepare actions.
Returns:
getEnablePrepareOnFirstPreparedStatementCall
public abstract boolean getEnablePrepareOnFirstPreparedStatementCall()
Returns the behavior for a specific connection instance. If false the first execution will call sp_executesql and not prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only executed once. The default for this option can be changed by calling setDefaultEnablePrepareOnFirstPreparedStatementCall().
Returns:
getIPAddressPreference
public abstract String getIPAddressPreference()
Gets the name of the preferred type of IP Address.
Returns:
getIgnoreOffsetOnDateTimeOffsetConversion
public abstract boolean getIgnoreOffsetOnDateTimeOffsetConversion()
Returns the current flag value for ignoreOffsetOnDateTimeOffsetConversion.
Returns:
getMsiTokenCacheTtl
(=12.1.0,=true)
public abstract int getMsiTokenCacheTtl()
Deprecated
This method will always return 0 and is for backwards compatibility only.
Returns:
getPrepareMethod
public abstract String getPrepareMethod()
Returns the behavior for a specific connection instance. PrepareMethod
Returns:
getSendTimeAsDatetime
public abstract boolean getSendTimeAsDatetime()
Returns the value of the sendTimeAsDatetime property.
Returns:
Throws:
getServerMessageHandler
public abstract ISQLServerMessageHandler getServerMessageHandler()
Get Currently installed message handler on the connection
Returns:
getServerPreparedStatementDiscardThreshold
public abstract int getServerPreparedStatementDiscardThreshold()
Returns the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is <= 1, unprepare actions will be executed immediately on prepared statement close. If it is set to > 1, these calls will be batched together to avoid overhead of calling sp_unprepare too often. The default for this option can be changed by calling getDefaultServerPreparedStatementDiscardThreshold().
Returns:
getStatementHandleCacheEntryCount
public abstract int getStatementHandleCacheEntryCount()
Returns the current number of pooled prepared statement handles.
Returns:
getStatementPoolingCacheSize
public abstract int getStatementPoolingCacheSize()
Returns the size of the prepared statement cache for this connection. A value less than 1 means no cache.
Returns:
getUseBulkCopyForBatchInsert
public abstract boolean getUseBulkCopyForBatchInsert()
Returns the useBulkCopyForBatchInsert value.
Returns:
getUseFmtOnly
public abstract boolean getUseFmtOnly()
Returns the current flag value for useFmtOnly.
Returns:
getcacheBulkCopyMetadata
public abstract boolean getcacheBulkCopyMetadata()
Sets the value for 'cacheBulkCopyMetadata' property
Returns:
isStatementPoolingEnabled
public abstract boolean isStatementPoolingEnabled()
Returns whether statement pooling is enabled or not for this connection.
Returns:
prepareCall
public abstract CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden.
Parameters:
String object that is the SQL statement to be sent to the database; may contain on or more
'?' parameters
ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
ResultSet constants: ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLE
ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
CallableStatement object, containing the pre-compiled SQL statement, that will
generate ResultSet objects with the given type, concurrency, and holdabilityThrows:
ResultSet constants indicating type, concurrency, and holdability
prepareStatement
public abstract PreparedStatement prepareStatement(String sql, int flag, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling #getHoldability.
Parameters:
Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
Returns:
PreparedStatement object, containing the pre-compiled SQL statement, that will have
the capability of returning auto-generated keysThrows:
Statement constant indicating whether auto-generated keys should be returned
prepareStatement
public abstract PreparedStatement prepareStatement(String sql, int nType, int nConcur, int resultSetHoldability, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.
Parameters:
String object that is the SQL statement to be sent to the database; may contain one or more
'?' IN parameters
ResultSet constants: ResultSet.TYPE_FORWARD_ONLY,
ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
ResultSet constants: ResultSet.CONCUR_READ_ONLY or
ResultSet.CONCUR_UPDATABLE
ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
PreparedStatement object, containing the pre-compiled SQL statement, that will
generate ResultSet objects with the given type, concurrency, and holdabilityThrows:
ResultSet constants indicating type, concurrency, and holdability
prepareStatement
public abstract PreparedStatement prepareStatement(String sql, int[] columnIndexes, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling #getHoldability.
Parameters:
Returns:
PreparedStatement object, containing the pre-compiled statement, that is capable of
returning the auto-generated keys designated by the given array of column indexesThrows:
prepareStatement
public abstract PreparedStatement prepareStatement(String sql, String[] columnNames, SQLServerStatementColumnEncryptionSetting stmtColEncSetting)
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. The driver will ignore the array if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.
Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.
Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling #getHoldability.
Parameters:
Returns:
PreparedStatement object, containing the pre-compiled statement, that is capable of
returning the auto-generated keys designated by the given array of column namesThrows:
setAccessTokenCallbackClass
public abstract void setAccessTokenCallbackClass(String accessTokenCallbackClass)
Sets 'accessTokenCallbackClass' to the fully qualified class name of the implementing class for SQLServerAccessTokenCallback.
Parameters:
setCalcBigDecimalPrecision
public abstract void setCalcBigDecimalPrecision(boolean calcBigDecimalPrecision)
Specifies whether to calculate precision from inputted big decimal values.
Parameters:
setDatetimeParameterType
public abstract void setDatetimeParameterType(String datetimeParameterTypeValue)
Sets the value of the datetimeParameterType connection property, which controls how date and time parameters are sent to the server against SQL Server 2008+. This setting can affect server-side date conversions and comparisons during statement execution, particularly against SQL Server 2016+. By default, the value is set to "datetime2". Valid values are: datetime, datetime2 or datetimeoffset.
Parameters:
Throws:
setDelayLoadingLobs
public abstract void setDelayLoadingLobs(boolean delayLoadingLobs)
Specifies the flag to immediately load LOB objects into memory.
Parameters:
setDisableStatementPooling
public abstract void setDisableStatementPooling(boolean value)
Sets the value to Disable/enable statement pooling.
Parameters:
setEnablePrepareOnFirstPreparedStatementCall
public abstract void setEnablePrepareOnFirstPreparedStatementCall(boolean value)
Sets the behavior for a specific connection instance. If value is false the first execution will call sp_executesql and not prepare a statement, once the second execution happens it will call sp_prepexec and actually setup a prepared statement handle. Following executions will call sp_execute. This relieves the need for sp_unprepare on prepared statement close if the statement is only executed once.
Parameters:
setIPAddressPreference
public abstract void setIPAddressPreference(String iPAddressPreference)
Sets the name of the preferred type of IP Address.
Parameters:
setIgnoreOffsetOnDateTimeOffsetConversion
public abstract void setIgnoreOffsetOnDateTimeOffsetConversion(boolean ignoreOffsetOnDateTimeOffsetConversion)
Specifies the flag to ignore offset when converting DATETIMEOFFSET to LocalDateTime.
Parameters:
setMsiTokenCacheTtl
(=12.1.0,=true)
public abstract void setMsiTokenCacheTtl(int timeToLive)
Deprecated
Time-to-live is no longer supported for the cached Managed Identity tokens. This method is a no-op for backwards compatibility only.
Parameters:
setPrepareMethod
public abstract void setPrepareMethod(String prepareMethod)
Sets the behavior for the prepare method. PrepareMethod
Parameters:
setSendTimeAsDatetime
public abstract void setSendTimeAsDatetime(boolean sendTimeAsDateTimeValue)
Sets the value of the sendTimeAsDatetime connection property. When true, java.sql.Time values will be sent to the server as SQL Serverdatetime values. When false, java.sql.Time values will be sent to the server as SQL Servertime values. sendTimeAsDatetime can also be modified programmatically with SQLServerDataSource.setSendTimeAsDatetime. The default value for this property may change in a future release.
Parameters:
Throws:
setServerMessageHandler
public abstract ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler)
Set message handler on the connection
Parameters:
Returns:
setServerPreparedStatementDiscardThreshold
public abstract void setServerPreparedStatementDiscardThreshold(int value)
Sets the behavior for a specific connection instance. This setting controls how many outstanding prepared statement discard actions (sp_unprepare) can be outstanding per connection before a call to clean-up the outstanding handles on the server is executed. If the setting is <= 1 unprepare actions will be executed immedietely on prepared statement close. If it is set to > 1 these calls will be batched together to avoid overhead of calling sp_unprepare too often.
Parameters:
setStatementPoolingCacheSize
public abstract void setStatementPoolingCacheSize(int value)
Sets the size of the prepared statement cache for this connection. A value less than 1 means no cache.
Parameters:
setUseBulkCopyForBatchInsert
public abstract void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert)
Specifies the flag for using Bulk Copy API for batch insert operations.
Parameters:
setUseFmtOnly
public abstract void setUseFmtOnly(boolean useFmtOnly)
Specifies the flag to use FMTONLY for parameter metadata queries.
Parameters:
setcacheBulkCopyMetadata
public abstract void setcacheBulkCopyMetadata(boolean cacheBulkCopyMetadata)
Returns value of 'cacheBulkCopyMetadata' from Connection String.
Parameters: