diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java index a6054b1fc..e0e4eebbf 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java @@ -485,17 +485,22 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold, /** * Get Currently installed message handler on the connection - * @see {@link ISQLServerMessageHandler#messageHandler(ISQLServerMessage)} - * @return + * + * @see ISQLServerMessageHandler#messageHandler(ISQLServerMessage) + * @return ISQLServerMessageHandler */ ISQLServerMessageHandler getServerMessageHandler(); /** * Set message handler on the connection - * @see {@link ISQLServerMessageHandler#messageHandler(ISQLServerMessage)} + * + * @param messageHandler + * message handler + * + * @see ISQLServerMessageHandler#messageHandler(ISQLServerMessage) */ ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler); - + /** * Returns the current flag for calcBigDecimalPrecision. * diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessage.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessage.java index 055e812b2..622b865c3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessage.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessage.java @@ -6,8 +6,11 @@ import java.sql.SQLException; -public interface ISQLServerMessage -{ + +/** + * Provides an interface SQLServerMessage + */ +public interface ISQLServerMessage { /** * Returns SQLServerError containing detailed info about SQL Server Message as received from SQL Server. * @@ -67,16 +70,18 @@ public interface ISQLServerMessage /** * Creates a SQLServerException or SQLServerWarning from this SQLServerMessage
+ * * @return - * + * */ public SQLException toSqlExceptionOrSqlWarning(); /** * Check if this is a isErrorMessage + * * @return true if it's an instance of SQLServerError */ public default boolean isErrorMessage() { @@ -85,6 +90,7 @@ public default boolean isErrorMessage() { /** * Check if this is a SQLServerInfoMessage + * * @return true if it's an instance of SQLServerInfoMessage */ public default boolean isInfoMessage() { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessageHandler.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessageHandler.java index 74d7d7518..2f0b71de7 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessageHandler.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerMessageHandler.java @@ -5,99 +5,99 @@ package com.microsoft.sqlserver.jdbc; /** - * You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server. + * You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server. * Implementing ISQLServerMessageHandler in your own class for handling error messages can provide the following benefits: * *

* For example code, see {@link #messageHandler(ISQLServerMessage)} */ -public interface ISQLServerMessageHandler -{ +public interface ISQLServerMessageHandler { /** - * You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server. + * You can use the ISQLServerMessageHandler interface to customize the way JDBC handles error messages generated by the SQL Server. * Implementing ISQLServerMessageHandler in your own class for handling error messages can provide the following benefits: *

* * Example code: + * *
-     *  public ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning)
-     *  {
-     *      ISQLServerMessage retObj = serverErrorOrWarning;
+     * public ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning) {
+     *     ISQLServerMessage retObj = serverErrorOrWarning;
      *
-     *      if (serverErrorOrWarning.isErrorMessage()) {
+     *     if (serverErrorOrWarning.isErrorMessage()) {
      *
-     *          // Downgrade: 2601 -- Cannot insert duplicate key row...
-     *          if (2601 == serverErrorOrWarning.getErrorNumber()) {
-     *              retObj = serverErrorOrWarning.getSQLServerMessage().toSQLServerInfoMessage();
-     *          }
+     *         // Downgrade: 2601 -- Cannot insert duplicate key row...
+     *         if (2601 == serverErrorOrWarning.getErrorNumber()) {
+     *             retObj = serverErrorOrWarning.getSQLServerMessage().toSQLServerInfoMessage();
+     *         }
      *
-     *          // Discard: 3701 -- Cannot drop the table ...
-     *          if (3701 == serverErrorOrWarning.getErrorNumber()) {
-     *              retObj = null;
-     *          }
-     *      }
+     *         // Discard: 3701 -- Cannot drop the table ...
+     *         if (3701 == serverErrorOrWarning.getErrorNumber()) {
+     *             retObj = null;
+     *         }
+     *     }
      *
-     *      return retObj;
-     *  }
-    
+     *     return retObj;
+     * }
+     * 
      * 
* * @param serverErrorOrWarning - * @return - * + * server error or warning + * @return + * */ ISQLServerMessage messageHandler(ISQLServerMessage serverErrorOrWarning); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java b/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java index e388ac90b..24458a7f3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/PersistentTokenCacheAccessAspect.java @@ -65,10 +65,21 @@ public void afterCacheAccess(ITokenCacheAccessContext iTokenCacheAccessContext) } + /** + * Get expiry time + * + * @return expiry time + */ public long getExpiryTime() { return this.expiryTime; } + /** + * Set expiry time + * + * @param expiryTime + * expiry time + */ public void setExpiryTime(long expiryTime) { this.expiryTime = expiryTime; } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java index 89a433f08..42281688a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java @@ -919,6 +919,22 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow return isValid; } + /** + * Sign column master key metadata + * + * @param masterKeyPath + * master key path + * + * @param allowEnclaveComputations + * flag whether to allow enclave computations + * + * @return + * column master key metadata + * + * @throws SQLServerException + * when an error occurs + * + */ public byte[] signColumnMasterKeyMetadata(String masterKeyPath, boolean allowEnclaveComputations) throws SQLServerException { if (!allowEnclaveComputations) { diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java index 50359f04a..d2e2f28c4 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionJavaKeyStoreProvider.java @@ -164,6 +164,22 @@ public boolean verifyColumnMasterKeyMetadata(String masterKeyPath, boolean allow return isValid; } + /** + * Sign column master key metadata + * + * @param masterKeyPath + * master key path + * + * @param allowEnclaveComputations + * flag whether to allow enclave computations + * + * @return + * column master key metadata + * + * @throws SQLServerException + * when an error occurs + * + */ public byte[] signColumnMasterKeyMetadata(String masterKeyPath, boolean allowEnclaveComputations) throws SQLServerException { if (!allowEnclaveComputations) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 19f72cbc1..8012bea5c 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -1053,6 +1053,9 @@ public void setIgnoreOffsetOnDateTimeOffsetConversion(boolean ignoreOffsetOnDate this.ignoreOffsetOnDateTimeOffsetConversion = ignoreOffsetOnDateTimeOffsetConversion; } + /** + * Flag to indicate whether the driver should calculate precision for BigDecimal inputs, as opposed to using the maximum allowed valued for precision (38). + */ private boolean calcBigDecimalPrecision = SQLServerDriverBooleanProperty.CALC_BIG_DECIMAL_PRECISION .getDefaultValue(); @@ -8521,31 +8524,28 @@ public String getIPAddressPreference() { return activeConnectionProperties.getProperty(SQLServerDriverStringProperty.IPADDRESS_PREFERENCE.toString()); } - - /** Message handler */ private transient ISQLServerMessageHandler serverMessageHandler; - + /** * Set current message handler * * @param messageHandler + * message handler * @return The previously installed message handler (null if none) */ @Override - public ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler) - { - ISQLServerMessageHandler installedMessageHandler = this.serverMessageHandler; - this.serverMessageHandler = messageHandler; + public ISQLServerMessageHandler setServerMessageHandler(ISQLServerMessageHandler messageHandler) { + ISQLServerMessageHandler installedMessageHandler = this.serverMessageHandler; + this.serverMessageHandler = messageHandler; return installedMessageHandler; - } + } /** * @return Get Currently installed message handler on the connection */ @Override - public ISQLServerMessageHandler getServerMessageHandler() - { + public ISQLServerMessageHandler getServerMessageHandler() { return this.serverMessageHandler; } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 2dfb40d89..5c23a4777 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -268,7 +268,10 @@ private void checkClosed() throws SQLServerException { // Use LinkedHashMap to force retrieve elements in order they were inserted /** getColumns columns */ private LinkedHashMap getColumnsDWColumns = null; + + /** getTypes columns */ private LinkedHashMap getTypesDWColumns = null; + /** getImportedKeys columns */ private volatile LinkedHashMap getImportedKeysDWColumns; private static final Lock LOCK = new ReentrantLock(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerError.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerError.java index 1b4c1e836..b3e96904f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerError.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerError.java @@ -226,15 +226,15 @@ public long getLineNumber() { SQLServerError(SQLServerError errorMsg) { super(TDS.TDS_ERR); - this.errorNumber = errorMsg.errorNumber; - this.errorState = errorMsg.errorState; + this.errorNumber = errorMsg.errorNumber; + this.errorState = errorMsg.errorState; this.errorSeverity = errorMsg.errorSeverity; - this.errorMessage = errorMsg.errorMessage; - this.serverName = errorMsg.serverName; - this.procName = errorMsg.procName; - this.lineNumber = errorMsg.lineNumber; + this.errorMessage = errorMsg.errorMessage; + this.serverName = errorMsg.serverName; + this.procName = errorMsg.procName; + this.lineNumber = errorMsg.lineNumber; } - + @Override void setFromTDS(TDSReader tdsReader) throws SQLServerException { if (TDS.TDS_ERR != tdsReader.readUnsignedByte()) @@ -253,16 +253,14 @@ void setContentsFromTDS(TDSReader tdsReader) throws SQLServerException { lineNumber = tdsReader.readUnsignedInt(); } - - - /** + /** * Holds any "overflow messages", or messages that has been added after the first message. *

* This is later on used when creating a SQLServerException.
* Where all entries in the errorChain will be added {@link java.sql.SQLException#setNextException(SQLException)} */ private List errorChain; - + void addError(SQLServerError sqlServerError) { if (errorChain == null) { errorChain = new ArrayList<>(); @@ -273,51 +271,51 @@ void addError(SQLServerError sqlServerError) { List getErrorChain() { return errorChain; } - + @Override - public SQLServerError getSQLServerMessage() - { + public SQLServerError getSQLServerMessage() { return this; } /** * Downgrade a Error message into a Info message *

- * This simply create a SQLServerInfoMessage from this SQLServerError, - * without changing the message content. - * @return + * This simply create a SQLServerInfoMessage from this SQLServerError, + * without changing the message content. + * + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerInfoMessage() - { + public ISQLServerMessage toSQLServerInfoMessage() { return toSQLServerInfoMessage(-1, -1); } /** * Downgrade a Error message into a Info message *

- * This simply create a SQLServerInfoMessage from this SQLServerError, + * This simply create a SQLServerInfoMessage from this SQLServerError, * - * @param newErrorSeverity - The new ErrorSeverity + * @param newErrorSeverity + * - The new ErrorSeverity * - * @return + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerInfoMessage(int newErrorSeverity) - { + public ISQLServerMessage toSQLServerInfoMessage(int newErrorSeverity) { return toSQLServerInfoMessage(newErrorSeverity, -1); } /** * Downgrade a Error message into a Info message *

- * This simply create a SQLServerInfoMessage from this SQLServerError, + * This simply create a SQLServerInfoMessage from this SQLServerError, * - * @param newErrorSeverity - If you want to change the ErrorSeverity (-1: leave unchanged) - * @param newErrorNumber - If you want to change the ErrorNumber (-1: leave unchanged) + * @param newErrorSeverity + * - If you want to change the ErrorSeverity (-1: leave unchanged) + * @param newErrorNumber + * - If you want to change the ErrorNumber (-1: leave unchanged) * - * @return + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerInfoMessage(int newErrorSeverity, int newErrorNumber) - { + public ISQLServerMessage toSQLServerInfoMessage(int newErrorSeverity, int newErrorNumber) { if (newErrorSeverity != -1) { this.setErrorSeverity(newErrorSeverity); } @@ -331,25 +329,26 @@ public ISQLServerMessage toSQLServerInfoMessage(int newErrorSeverity, int newErr /** * Set a new ErrorSeverity for this Message + * * @param newSeverity + * new severity */ - public void setErrorSeverity(int newSeverity) - { + public void setErrorSeverity(int newSeverity) { this.errorSeverity = newSeverity; } /** * Set a new ErrorNumber for this Message - * @param newSeverity + * + * @param newErrorNumber + * new error number */ - public void setErrorNumber(int newErrorNumber) - { + public void setErrorNumber(int newErrorNumber) { this.errorNumber = newErrorNumber; } - + @Override - public SQLException toSqlExceptionOrSqlWarning() - { + public SQLException toSqlExceptionOrSqlWarning() { return new SQLServerException(this); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerInfoMessage.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerInfoMessage.java index 8b6579491..0b3a6075a 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerInfoMessage.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerInfoMessage.java @@ -7,10 +7,11 @@ import java.sql.SQLException; + /** * Holds information about SQL Server messages that is considered as Informational Messages (normally if SQL Server Severity is at 10) *

- * Instead of just holding the SQL Server message (like a normal SQLWarning, it also holds all the + * Instead of just holding the SQL Server message (like a normal SQLWarning, it also holds all the * SQL Servers extended information, like: ErrorSeverity, ServerName, ProcName etc *

* This enables client to print out extra information about the message.
@@ -46,77 +47,76 @@ public SQLServerError getSQLServerMessage() { public String getErrorMessage() { return msg.getErrorMessage(); } - + @Override public int getErrorNumber() { return msg.getErrorNumber(); } - + @Override public int getErrorState() { return msg.getErrorState(); } - + @Override public int getErrorSeverity() { return msg.getErrorSeverity(); } - + @Override public String getServerName() { return msg.getServerName(); } - + @Override - public String getProcedureName() - { + public String getProcedureName() { return msg.getProcedureName(); } - + @Override - public long getLineNumber() - { + public long getLineNumber() { return msg.getLineNumber(); } /** * Upgrade a Info message into a Error message *

- * This simply create a SQLServerError from this SQLServerInfoMessage, - * without changing the message content. - * @return + * This simply create a SQLServerError from this SQLServerInfoMessage, + * without changing the message content. + * + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerError() - { + public ISQLServerMessage toSQLServerError() { return toSQLServerError(-1, -1); } /** * Upgrade a Info message into a Error message *

- * This simply create a SQLServerError from this SQLServerInfoMessage. + * This simply create a SQLServerError from this SQLServerInfoMessage. * - * @param newErrorSeverity - The new ErrorSeverity + * @param newErrorSeverity + * - The new ErrorSeverity * - * @return + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerError(int newErrorSeverity) - { + public ISQLServerMessage toSQLServerError(int newErrorSeverity) { return toSQLServerError(newErrorSeverity, -1); } /** * Upgrade a Info message into a Error message *

- * This simply create a SQLServerError from this SQLServerInfoMessage. + * This simply create a SQLServerError from this SQLServerInfoMessage. * - * @param newErrorSeverity - If you want to change the ErrorSeverity (-1: leave unchanged) - * @param newErrorNumber - If you want to change the ErrorNumber (-1: leave unchanged) + * @param newErrorSeverity + * - If you want to change the ErrorSeverity (-1: leave unchanged) + * @param newErrorNumber + * - If you want to change the ErrorNumber (-1: leave unchanged) * - * @return + * @return ISQLServerMessage */ - public ISQLServerMessage toSQLServerError(int newErrorSeverity, int newErrorNumber) - { + public ISQLServerMessage toSQLServerError(int newErrorSeverity, int newErrorNumber) { if (newErrorSeverity != -1) { this.msg.setErrorSeverity(newErrorSeverity); } @@ -129,8 +129,7 @@ public ISQLServerMessage toSQLServerError(int newErrorSeverity, int newErrorNumb } @Override - public SQLException toSqlExceptionOrSqlWarning() - { + public SQLException toSqlExceptionOrSqlWarning() { return new SQLServerWarning(this.msg); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java index 294a1aa87..4274e6913 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java @@ -71,10 +71,13 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS /** Processed SQL statement text, may not be same as what user initially passed. */ final String userSQL; + // flag whether is exec escape syntax private boolean isExecEscapeSyntax; + // flag whether is call escape syntax private boolean isCallEscapeSyntax; + // flag whether is four part syntax private boolean isFourPartSyntax; /** Parameter positions in processed SQL statement text. */