Repository: microsoft/mssql-jdbc
Pull request #1969 (2022-11-16 21:27:20)

More fixes for SonarQube warnings and coding standards
address warnings from SonarQube scan and also some changes to adhere to coding standasrd


Patch:
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
index 8c88d4e7..abf2d741 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
@@ -201,7 +201,7 @@ final class DDC {
      * @return the byte array containing the big-endian encoded value.
      */
     static final byte[] convertIntToBytes(int intValue, int valueLength) {
-        byte bytes[] = new byte[valueLength];
+        byte[] bytes = new byte[valueLength];
         for (int i = valueLength; i-- > 0;) {
             bytes[i] = (byte) (intValue & 0xFF);
             intValue >>= 8;
@@ -258,7 +258,7 @@ final class DDC {
      * @return the byte array containing the big-endian encoded value.
      */
     static final byte[] convertLongToBytes(long longValue) {
-        byte bytes[] = new byte[8];
+        byte[] bytes = new byte[8];
         for (int i = 8; i-- > 0;) {
             bytes[i] = (byte) (longValue & 0xFF);
             longValue >>= 8;
@@ -564,7 +564,7 @@ final class DDC {
                 return parseStringIntoLDT(stringVal.trim());
             case DATE:
                 return java.sql.Date.valueOf(getDatePart(stringVal.trim()));
-            case TIME: {
+            case TIME:
                 // Accepted character formats for conversion to java.sql.Time are:
                 // hh:mm:ss[.nnnnnnnnn]
                 // YYYY-MM-DD hh:mm:ss[.nnnnnnnnn]
@@ -582,7 +582,6 @@ final class DDC {
                     cal.add(Calendar.MILLISECOND, 1);
                 cal.set(TDS.BASE_YEAR_1970, Calendar.JANUARY, 1);
                 return new java.sql.Time(cal.getTimeInMillis());
-            }
 
             case BINARY:
                 return stringVal.getBytes(charset);
@@ -924,7 +923,7 @@ final class DDC {
         // Set the calendar value according to the specified local time zone and constituent
         // date (days since base date) and time (ticks since midnight) parts.
         switch (ssType) {
-            case TIME: {
+            case TIME:
                 // Set the calendar to the specified value. Lenient calendar behavior will update
                 // individual fields according to standard Gregorian leap year rules, which are sufficient
                 // for all TIME values.
@@ -940,11 +939,10 @@ final class DDC {
 
                 subSecondNanos = (int) (ticksSinceMidnight % Nanos.PER_SECOND);
                 break;
-            }
 
             case DATE:
             case DATETIME2:
-            case DATETIMEOFFSET: {
+            case DATETIMEOFFSET:
                 // For dates after the standard Julian-Gregorian calendar change date,
                 // the calendar value can be accurately set using a straightforward
                 // (and measurably better performing) assignment.
@@ -1012,10 +1010,8 @@ final class DDC {
 
                 subSecondNanos = (int) (ticksSinceMidnight % Nanos.PER_SECOND);
                 break;
-            }
 
             case DATETIME: // and SMALLDATETIME
-            {
                 // For Yukon (and earlier) data types DATETIME and SMALLDATETIME, there is no need to
                 // change the Gregorian cutover because the earliest representable value (1/1/1753)
                 // is after the historically standard cutover date (10/15/1582).
@@ -1030,7 +1026,6 @@ final class DDC {
 
                 subSecondNanos = (int) ((ticksSinceMidnight * Nanos.PER_MILLISECOND) % Nanos.PER_SECOND);
                 break;
-            }
 
             default:
                 MessageFormat form = new MessageFormat(
@@ -1043,9 +1038,9 @@ final class DDC {
         // Convert the calendar value (in local time) to the desired Java object type.
         switch (jdbcType.category) {
             case BINARY:
-            case SQL_VARIANT: {
+            case SQL_VARIANT:
                 switch (ssType) {
-                    case DATE: {
+                    case DATE:
                         // Per JDBC spec, the time part of java.sql.Date values is initialized to midnight
                         // in the specified local time zone.
                         cal.set(Calendar.HOUR_OF_DAY, 0);
@@ -1053,14 +1048,12 @@ final class DDC {
                         cal.set(Calendar.SECOND, 0);
                         cal.set(Calendar.MILLISECOND, 0);
                         return new java.sql.Date(cal.getTimeInMillis());
-                    }
 
                     case DATETIME:
-                    case DATETIME2: {
+                    case DATETIME2:
                         java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis());
                         ts.setNanos(subSecondNanos);
                         return ts;
-                    }
 
                     case DATETIMEOFFSET: {
                         // Per driver spec, conversion to DateTimeOffset is only supported from
@@ -1074,12 +1067,12 @@ final class DDC {
                         // milliseconds precision results in no loss of precision.
                         assert 0 == localMillisOffset % (60 * 1000);
 
-                        java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis());
-                        ts.setNanos(subSecondNanos);
-                        return microsoft.sql.DateTimeOffset.valueOf(ts, localMillisOffset / (60 * 1000));
+                        java.sql.Timestamp ts1 = new java.sql.Timestamp(cal.getTimeInMillis());
+                        ts1.setNanos(subSecondNanos);
+                        return microsoft.sql.DateTimeOffset.valueOf(ts1, localMillisOffset / (60 * 1000));
                     }
 
-                    case TIME: {
+                    case TIME:
                         // Per driver spec, values of sql server data types types (including TIME) which have greater
                         // than millisecond precision are rounded, not truncated, to the nearest millisecond when
                         // converting to java.sql.Time. Since the milliseconds value in the calendar is truncated,
@@ -1094,7 +1087,6 @@ final class DDC {
                         cal.set(TDS.BASE_YEAR_1970, Calendar.JANUARY, 1);
 
                         return new java.sql.Time(cal.getTimeInMillis());
-                    }
 
                     default:
                         MessageFormat form = new MessageFormat(
@@ -1102,9 +1094,8 @@ final class DDC {
                         throw new SQLServerException(form.format(new Object[] {ssType.name(), jdbcType}), null, 0,
                                 null);
                 }
-            }
 
-            case DATE: {
+            case DATE:
                 // Per JDBC spec, the time part of java.sql.Date values is initialized to midnight
                 // in the specified local time zone.
                 cal.set(Calendar.HOUR_OF_DAY, 0);
@@ -1112,9 +1103,8 @@ final class DDC {
                 cal.set(Calendar.SECOND, 0);
                 cal.set(Calendar.MILLISECOND, 0);
                 return new java.sql.Date(cal.getTimeInMillis());
-            }
 
-            case TIME: {
+            case TIME:
                 // Per driver spec, values of sql server data types types (including TIME) which have greater
                 // than millisecond precision are rounded, not truncated, to the nearest millisecond when
                 // converting to java.sql.Time. Since the milliseconds value in the calendar is truncated,
@@ -1129,18 +1119,16 @@ final class DDC {
                 cal.set(TDS.BASE_YEAR_1970, Calendar.JANUARY, 1);
 
                 return new java.sql.Time(cal.getTimeInMillis());
-            }
 
-            case TIMESTAMP: {
-                java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis());
-                ts.setNanos(subSecondNanos);
+            case TIMESTAMP:
+                java.sql.Timestamp ts2 = new java.sql.Timestamp(cal.getTimeInMillis());
+                ts2.setNanos(subSecondNanos);
                 if (jdbcType == JDBCType.LOCALDATETIME) {
-                    return ts.toLocalDateTime();
+                    return ts2.toLocalDateTime();
                 }
-                return ts;
-            }
+                return ts2;
 
-            case DATETIMEOFFSET: {
+            case DATETIMEOFFSET:
                 // Per driver spec, conversion to DateTimeOffset is only supported from
                 // DATETIMEOFFSET SQL Server values.
                 assert SSType.DATETIMEOFFSET == ssType;
@@ -1155,26 +1143,22 @@ final class DDC {
                 java.sql.Timestamp ts = new java.sql.Timestamp(cal.getTimeInMillis());
                 ts.setNanos(subSecondNanos);
                 return microsoft.sql.DateTimeOffset.valueOf(ts, localMillisOffset / (60 * 1000));
-            }
 
-            case CHARACTER: {
+            case CHARACTER:
                 switch (ssType) {
-                    case DATE: {
+                    case DATE:
                         return String.format(Locale.US, "%1$tF", // yyyy-mm-dd
                                 cal);
-                    }
 
-                    case TIME: {
+                    case TIME:
                         return String.format(Locale.US, "%1$tT%2$s", // hh:mm:ss[.nnnnnnn]
                                 cal, fractionalSecondsString(subSecondNanos, fractionalSecondsScale));
-                    }
 
-                    case DATETIME2: {
+                    case DATETIME2:
                         return String.format(Locale.US, "%1$tF %1$tT%2$s", // yyyy-mm-dd hh:mm:ss[.nnnnnnn]
                                 cal, fractionalSecondsString(subSecondNanos, fractionalSecondsScale));
-                    }
 
-                    case DATETIMEOFFSET: {
+                    case DATETIMEOFFSET:
                         // The offset part of a DATETIMEOFFSET value is precise only to the minute,
                         // but TimeZone returns the raw offset as precise to the millisecond.
                         assert 0 == localMillisOffset % (60 * 1000);
@@ -1186,12 +1170,9 @@ final class DDC {
                                 cal, fractionalSecondsString(subSecondNanos, fractionalSecondsScale),
                                 (localMillisOffset >= 0) ? '+' : '-', unsignedMinutesOffset / 60,
                                 unsignedMinutesOffset % 60);
-                    }
 
                     case DATETIME: // and SMALLDATETIME
-                    {
                         return (new java.sql.Timestamp(cal.getTimeInMillis())).toString();
-                    }
 
                     default:
                         MessageFormat form = new MessageFormat(
@@ -1199,7 +1180,6 @@ final class DDC {
                         throw new SQLServerException(form.format(new Object[] {ssType.name(), jdbcType}), null, 0,
                                 null);
                 }
-            }
 
             default:
                 MessageFormat form = new MessageFormat(
@@ -1219,46 +1199,42 @@ final class DDC {
         LocalDateTime ldt;
 
         switch (ssType) {
-            case TIME: {
+            case TIME:
                 ldt = LocalDateTime.of(TDS.BASE_LOCAL_DATE_1900, LocalTime.ofNanoOfDay(ticksSinceMidnight));
 
                 subSecondNanos = (int) (ticksSinceMidnight % Nanos.PER_SECOND);
                 break;
-            }
 
             case DATE:
             case DATETIME2:
-            case DATETIMEOFFSET: {
-                LocalDate ld = TDS.BASE_LOCAL_DATE.plusDays(daysSinceBaseDate);
+            case DATETIMEOFFSET:
+                LocalDate ld1 = TDS.BASE_LOCAL_DATE.plusDays(daysSinceBaseDate);
                 // If the target is java.sql.Date or a datetime column is used to hold a timeless date, don't add the time component.
                 if (ticksSinceMidnight == 0) {
-                    ldt = LocalDateTime.of(ld, LocalTime.MIN);
+                    ldt = LocalDateTime.of(ld1, LocalTime.MIN);
                     subSecondNanos = 0;
                 } else {
-                    ldt = LocalDateTime.of(ld, LocalTime.ofNanoOfDay(ticksSinceMidnight));
+                    ldt = LocalDateTime.of(ld1, LocalTime.ofNanoOfDay(ticksSinceMidnight));
                     subSecondNanos = (int) (ticksSinceMidnight % Nanos.PER_SECOND);
                 }
                 break;
-            }
 
             case DATETIME: // and SMALLDATETIME
-            {
-                LocalDate ld = TDS.BASE_LOCAL_DATE_1900.plusDays(daysSinceBaseDate);
+                LocalDate ld2 = TDS.BASE_LOCAL_DATE_1900.plusDays(daysSinceBaseDate);
                 // If the target is java.sql.Date or a datetime column is used to hold a timeless date, don't add the time component.
                 if (ticksSinceMidnight == 0) {
-                    ldt = LocalDateTime.of(ld, LocalTime.MIN);
+                    ldt = LocalDateTime.of(ld2, LocalTime.MIN);
                     subSecondNanos = 0;
                 } else {
                     long nanoOfDay = ticksSinceMidnight * Nanos.PER_MILLISECOND;
                     if (nanoOfDay > LocalTime.MAX.toNanoOfDay()) {
-                        ldt = LocalDateTime.of(ld, LocalTime.MIN).plusNanos(nanoOfDay);
+                        ldt = LocalDateTime.of(ld2, LocalTime.MIN).plusNanos(nanoOfDay);
                     } else {
-                        ldt = LocalDateTime.of(ld, LocalTime.ofNanoOfDay(nanoOfDay));
+                        ldt = LocalDateTime.of(ld2, LocalTime.ofNanoOfDay(nanoOfDay));
                     }
                     subSecondNanos = (int) (nanoOfDay % Nanos.PER_SECOND);
                 }
                 break;
-            }
 
             default:
                 MessageFormat form = new MessageFormat(
@@ -1268,27 +1244,24 @@ final class DDC {
 
         switch (jdbcType.category) {
             case BINARY:
-            case SQL_VARIANT: {
+            case SQL_VARIANT:
                 switch (ssType) {
-                    case DATE: {
+                    case DATE:
                         return java.sql.Date.valueOf(ldt.toLocalDate());
-                    }
 
                     case DATETIME:
-                    case DATETIME2: {
+                    case DATETIME2:
                         java.sql.Timestamp ts = java.sql.Timestamp.valueOf(ldt);
                         ts.setNanos(subSecondNanos);
                         return ts;
-                    }
 
-                    case TIME: {
+                    case TIME:
                         if (subSecondNanos % Nanos.PER_MILLISECOND >= Nanos.PER_MILLISECOND / 2) {
                             ldt = ldt.plusNanos(1000000);
                         }
                         java.sql.Time t = java.sql.Time.valueOf(ldt.toLocalTime());
                         t.setTime(t.getTime() + (ldt.getNano() / Nanos.PER_MILLISECOND));
                         return t;
-                    }
 
                     default:
                         MessageFormat form = new MessageFormat(
@@ -1296,22 +1269,19 @@ final class DDC {
                         throw new SQLServerException(form.format(new Object[] {ssType.name(), jdbcType}), null, 0,
                                 null);
                 }
-            }
 
-            case DATE: {
+            case DATE:
                 return java.sql.Date.valueOf(ldt.toLocalDate());
-            }
 
-            case TIME: {
+            case TIME:
                 if (subSecondNanos % Nanos.PER_MILLISECOND >= Nanos.PER_MILLISECOND / 2) {
                     ldt = ldt.plusNanos(1000000);
                 }
                 java.sql.Time t = java.sql.Time.valueOf(ldt.toLocalTime());
                 t.setTime(t.getTime() + (ldt.getNano() / Nanos.PER_MILLISECOND));
                 return t;
-            }
 
-            case TIMESTAMP: {
+            case TIMESTAMP:
                 if (jdbcType == JDBCType.LOCALDATETIME) {
                     return ldt;
                 }
@@ -1319,30 +1289,24 @@ final class DDC {
                 java.sql.Timestamp ts = java.sql.Timestamp.valueOf(ldt);
                 ts.setNanos(subSecondNanos);
                 return ts;
-            }
 
-            case CHARACTER: {
+            case CHARACTER:
                 switch (ssType) {
-                    case DATE: {
+                    case DATE:
                         return String.format(Locale.US, "%1$tF", // yyyy-mm-dd
                                 java.sql.Timestamp.valueOf(ldt));
-                    }
 
-                    case TIME: {
+                    case TIME:
                         return String.format(Locale.US, "%1$tT%2$s", // hh:mm:ss[.nnnnnnn]
                                 ldt, fractionalSecondsString(subSecondNanos, fractionalSecondsScale));
-                    }
 
-                    case DATETIME2: {
+                    case DATETIME2:
                         return String.format(Locale.US, "%1$tF %1$tT%2$s", // yyyy-mm-dd hh:mm:ss[.nnnnnnn]
                                 java.sql.Timestamp.valueOf(ldt),
                                 fractionalSecondsString(subSecondNanos, fractionalSecondsScale));
-                    }
 
                     case DATETIME: // and SMALLDATETIME
-                    {
                         return (java.sql.Timestamp.valueOf(ldt)).toString();
-                    }
 
                     default:
                         MessageFormat form = new MessageFormat(
@@ -1350,7 +1314,6 @@ final class DDC {
                         throw new SQLServerException(form.format(new Object[] {ssType.name(), jdbcType}), null, 0,
                                 null);
                 }
-            }
 
             default:
                 MessageFormat form = new MessageFormat(
@@ -1436,7 +1399,7 @@ final class DDC {
             // Set up the buffer into which blocks of characters are read from the Reader. This buffer
             // should be no larger than the Reader value's size (if known). For known very large values,
             // limit the buffer's size to reduce this function's memory requirements.
-            char charArray[] = new char[(DataTypes.UNKNOWN_STREAM_LENGTH != readerLength
+            char[] charArray = new char[(DataTypes.UNKNOWN_STREAM_LENGTH != readerLength
                     && readerLength < 4000) ? readerLength : 4000];
 
             // Loop and read characters, chunk into StringBuilder until EOS.
@@ -1529,7 +1492,7 @@ final class AsciiFilteredInputStream extends InputStream {
     }
 
     @Override
-    public int read(byte b[], int offset, int maxBytes) throws IOException {
+    public int read(byte[] b, int offset, int maxBytes) throws IOException {
         int bytesRead = containedStream.read(b, offset, maxBytes);
         if (bytesRead > 0) {
             assert offset + bytesRead <= b.length;
@@ -1612,7 +1575,7 @@ final class AsciiFilteredUnicodeInputStream extends InputStream {
 
     @Override
     public int read(byte b[], int offset, int maxBytes) throws IOException {
-        char tempBufferToHoldCharDataForConversion[] = new char[maxBytes];
+        char[] tempBufferToHoldCharDataForConversion = new char[maxBytes];
         int charsRead = containedReader.read(tempBufferToHoldCharDataForConversion);
 
         if (charsRead > 0) {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
index ee7cda94..9e1d9e34 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/DLLException.java
@@ -60,15 +60,15 @@ class DLLException extends Exception {
         return this.errCode;
     }
 
-    String GetParam1() {
+    String getParam1() {
         return this.param1;
     }
 
-    String GetParam2() {
+    String getParam2() {
         return this.param2;
     }
 
-    String GetParam3() {
+    String getParam3() {
         return this.param3;
     }
 
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
index 487705dd..2e8a4a10 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/DataTypes.java
@@ -73,7 +73,7 @@ enum TDSType {
 
     private static final int MAXELEMENTS = 256;
     private static final TDSType[] VALUES = values();
-    private static final TDSType valuesTypes[] = new TDSType[MAXELEMENTS];
+    private static final TDSType[] valuesTypes = new TDSType[MAXELEMENTS];
 
     byte byteValue() {
         return (byte) intValue;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java
index e0c769c3..940e5dc9 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverInfo.java
@@ -31,7 +31,7 @@ final class FailoverInfo {
         return useFailoverPartner;
     }
 
-    FailoverInfo(String failover, SQLServerConnection con, boolean actualFailoverPartner) {
+    FailoverInfo(String failover, boolean actualFailoverPartner) {
         failoverPartner = failover;
         useFailoverPartner = actualFailoverPartner;
         portNumber = -1; // init to -1 to make sure that the user of this class calls the failover check before getting
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java
index 76fb5f5d..85afc11d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/FailOverMapSingleton.java
@@ -56,8 +56,7 @@ final class FailoverMapSingleton {
     // failover server name provided
     // by the server. The map is only populated if the server sends failover info.
     static void putFailoverInfo(SQLServerConnection connection, String primaryServer, String instance, String database,
-            FailoverInfo actualFailoverInfo, boolean actualuseFailover,
-            String failoverPartner) throws SQLServerException {
+            FailoverInfo actualFailoverInfo, boolean actualuseFailover, String failoverPartner) {
         FailoverInfo fo;
 
         LOCK.lock();
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
index fdb063b1..c27d06d6 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
@@ -1195,7 +1195,7 @@ final class TDSChannel implements Serializable {
                         if (logger.isLoggable(Level.FINER))
                             logger.finer(super.toString() + " " + e.getMessage());
 
-                        logger.finer(toString() + " Reading bytes threw exception:" + e.getMessage());
+                        logger.finer(super.toString() + " Reading bytes threw exception:" + e.getMessage());
                         throw e;
                     }
                 }
@@ -1403,7 +1403,7 @@ final class TDSChannel implements Serializable {
         }
 
         @Override
-        public int getReceiveBufferSize() throws SocketException {
+        public synchronized int getReceiveBufferSize() throws SocketException {
             return tdsChannel.tcpSocket.getReceiveBufferSize();
         }
 
@@ -1418,7 +1418,7 @@ final class TDSChannel implements Serializable {
         }
 
         @Override
-        public int getSendBufferSize() throws SocketException {
+        public synchronized int getSendBufferSize() throws SocketException {
             return tdsChannel.tcpSocket.getSendBufferSize();
         }
 
@@ -1428,7 +1428,7 @@ final class TDSChannel implements Serializable {
         }
 
         @Override
-        public int getSoTimeout() throws SocketException {
+        public synchronized int getSoTimeout() throws SocketException {
             return tdsChannel.tcpSocket.getSoTimeout();
         }
 
@@ -1499,19 +1499,19 @@ final class TDSChannel implements Serializable {
         // Ignore calls to methods that would otherwise allow the SSL socket
         // to directly manipulate the underlying TCP socket
         @Override
-        public void close() throws IOException {
+        public synchronized void close() throws IOException {
             if (logger.isLoggable(Level.FINER))
                 logger.finer(logContext + " Ignoring close");
         }
 
         @Override
-        public void setReceiveBufferSize(int size) throws SocketException {
+        public synchronized void setReceiveBufferSize(int size) throws SocketException {
             if (logger.isLoggable(Level.FINER))
                 logger.finer(toString() + " Ignoring setReceiveBufferSize size:" + size);
         }
 
         @Override
-        public void setSendBufferSize(int size) throws SocketException {
+        public synchronized void setSendBufferSize(int size) throws SocketException {
             if (logger.isLoggable(Level.FINER))
                 logger.finer(toString() + " Ignoring setSendBufferSize size:" + size);
         }
@@ -1529,7 +1529,7 @@ final class TDSChannel implements Serializable {
         }
 
         @Override
-        public void setSoTimeout(int timeout) throws SocketException {
+        public synchronized void setSoTimeout(int timeout) throws SocketException {
             tdsChannel.tcpSocket.setSoTimeout(timeout);
         }
 
@@ -2465,7 +2465,7 @@ final class SocketFinder {
             if (logger.isLoggable(Level.FINER)) {
                 StringBuilder loggingString = new StringBuilder(this.toString());
                 loggingString.append(" Total no of InetAddresses: ");
-                loggingString.append(inetAddrs.length);
+                loggingString.append((inetAddrs != null) ? inetAddrs.length : 0);
                 loggingString.append(". They are: ");
 
                 for (InetAddress inetAddr : inetAddrs) {
@@ -2475,7 +2475,7 @@ final class SocketFinder {
                 logger.finer(loggingString.toString());
             }
 
-            if (inetAddrs.length > IP_ADDRESS_LIMIT) {
+            if (inetAddrs != null && inetAddrs.length > IP_ADDRESS_LIMIT) {
                 MessageFormat form = new MessageFormat(
                         SQLServerException.getErrString("R_ipAddressLimitWithMultiSubnetFailover"));
                 Object[] msgArgs = {Integer.toString(IP_ADDRESS_LIMIT)};
@@ -2485,7 +2485,7 @@ final class SocketFinder {
                 conn.terminate(SQLServerException.DRIVER_ERROR_UNSUPPORTED_CONFIG, errorStr);
             }
 
-            if (inetAddrs.length == 1) {
+            if (inetAddrs != null && inetAddrs.length == 1) {
                 // Single address so do not start any threads
                 return getConnectedSocket(inetAddrs[0], portNumber, timeoutInMilliSeconds);
             }
@@ -3156,11 +3156,9 @@ final class SocketFinder {
             updatedException = true;
         }
 
-        if (updatedException) {
-            if (logger.isLoggable(Level.FINER)) {
-                logger.finer("The selected exception is updated to the following: ExceptionType:" + ex.getClass()
-                        + "; ExceptionMessage:" + ex.getMessage() + "; by the following thread:" + traceId);
-            }
+        if (updatedException && logger.isLoggable(Level.FINER)) {
+            logger.finer("The selected exception is updated to the following: ExceptionType:" + ex.getClass()
+                    + "; ExceptionMessage:" + ex.getMessage() + "; by the following thread:" + traceId);
         }
     }
 
@@ -3277,6 +3275,9 @@ final class SocketConnector implements Runnable {
  */
 final class TDSWriter {
     private static Logger logger = Logger.getLogger("com.microsoft.sqlserver.jdbc.internals.TDS.Writer");
+
+    private static final String UNEXPECTED_SSTYPE = "Unexpected SSType: ";
+
     private final String traceID;
 
     final public String toString() {
@@ -3334,9 +3335,6 @@ final class TDSWriter {
     private int packetNum = 0;
 
     // Bytes for sending decimal/numeric data
-    private final static int BYTES4 = 4;
-    private final static int BYTES8 = 8;
-    private final static int BYTES12 = 12;
     private final static int BYTES16 = 16;
     public final static int BIGDECIMAL_MAX_LENGTH = 0x11;
 
@@ -3399,13 +3397,12 @@ final class TDSWriter {
         if ((TDS.PKT_QUERY == tdsMessageType || TDS.PKT_DTC == tdsMessageType || TDS.PKT_RPC == tdsMessageType)) {
             boolean includeTraceHeader = false;
             int totalHeaderLength = TDS.MESSAGE_HEADER_LENGTH;
-            if (TDS.PKT_QUERY == tdsMessageType || TDS.PKT_RPC == tdsMessageType) {
-                if (con.isDenaliOrLater() && Util.isActivityTraceOn()
-                        && !ActivityCorrelator.getCurrent().isSentToServer()) {
-                    includeTraceHeader = true;
-                    totalHeaderLength += TDS.TRACE_HEADER_LENGTH;
-                }
+            if ((TDS.PKT_QUERY == tdsMessageType || TDS.PKT_RPC == tdsMessageType) && (con.isDenaliOrLater()
+                    && Util.isActivityTraceOn() && !ActivityCorrelator.getCurrent().isSentToServer())) {
+                includeTraceHeader = true;
+                totalHeaderLength += TDS.TRACE_HEADER_LENGTH;
             }
+
             writeInt(totalHeaderLength); // allHeaders.TotalLength (DWORD)
             writeInt(TDS.MARS_HEADER_LENGTH); // MARS header length (DWORD)
             writeShort((short) 2); // allHeaders.HeaderType(MARS header) (USHORT)
@@ -3638,9 +3635,9 @@ final class TDSWriter {
         // Byte array to hold all the data and padding bytes.
         byte[] bytes = new byte[bLength];
 
-        byte[] valueBytes = DDC.convertBigDecimalToBytes(bigDecimalVal, scale);
+        byte[] val = DDC.convertBigDecimalToBytes(bigDecimalVal, scale);
         // removing the precision and scale information from the valueBytes array
-        System.arraycopy(valueBytes, 2, bytes, 0, valueBytes.length - 2);
+        System.arraycopy(val, 2, bytes, 0, val.length - 2);
         writeBytes(bytes);
     }
 
@@ -3662,8 +3659,8 @@ final class TDSWriter {
         bLength = (srcJdbcType == microsoft.sql.Types.MONEY ? 8 : 4);
         writeByte((byte) (bLength));
 
-        byte[] valueBytes = DDC.convertMoneyToBytes(moneyVal, bLength);
-        writeBytes(valueBytes);
+        byte[] val = DDC.convertMoneyToBytes(moneyVal, bLength);
+        writeBytes(val);
     }
 
     /**
@@ -4103,7 +4100,7 @@ final class TDSWriter {
         }
     }
 
-    void writeWrappedBytes(byte value[], int valueLength) throws SQLServerException {
+    void writeWrappedBytes(byte[] value, int valueLength) throws SQLServerException {
         // This function should only be used to write a value that is longer than
         // what remains in the current staging buffer. However, the value must
         // be short enough to fit in an empty buffer.
@@ -4170,16 +4167,14 @@ final class TDSWriter {
         assert DataTypes.UNKNOWN_STREAM_LENGTH == advertisedLength || advertisedLength >= 0;
 
         long actualLength = 0;
-        final byte[] streamByteBuffer = new byte[4 * currentPacketSize];
+        final byte[] buff = new byte[4 * currentPacketSize];
         int bytesRead = 0;
         int bytesToWrite;
         do {
             // Read in next chunk
-            for (bytesToWrite = 0; -1 != bytesRead && bytesToWrite < streamByteBuffer.length;
-                    bytesToWrite += bytesRead) {
+            for (bytesToWrite = 0; -1 != bytesRead && bytesToWrite < buff.length; bytesToWrite += bytesRead) {
                 try {
-                    bytesRead = inputStream.read(streamByteBuffer, bytesToWrite,
-                            streamByteBuffer.length - bytesToWrite);
+                    bytesRead = inputStream.read(buff, bytesToWrite, buff.length - bytesToWrite);
                 } catch (IOException e) {
                     MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorReadingStream"));
                     Object[] msgArgs = {e.toString()};
@@ -4190,7 +4185,7 @@ final class TDSWriter {
                     break;
 
                 // Check for invalid bytesRead returned from InputStream.read
-                if (bytesRead < 0 || bytesRead > streamByteBuffer.length - bytesToWrite) {
+                if (bytesRead < 0 || bytesRead > buff.length - bytesToWrite) {
                     MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_errorReadingStream"));
                     Object[] msgArgs = {SQLServerException.getErrString("R_streamReadReturnedInvalidValue")};
                     error(form.format(msgArgs), SQLState.DATA_EXCEPTION_NOT_SPECIFIC, DriverError.NOT_SET);
@@ -4201,7 +4196,7 @@ final class TDSWriter {
             if (writeChunkSizes)
                 writeInt(bytesToWrite);
 
-            writeBytes(streamByteBuffer, 0, bytesToWrite);
+            writeBytes(buff, 0, bytesToWrite);
             actualLength += bytesToWrite;
         } while (-1 != bytesRead || bytesToWrite > 0);
 
@@ -4756,8 +4751,8 @@ final class TDSWriter {
         writeByte((byte) 0x11); // maximum length
         writeByte((byte) SQLServerConnection.maxDecimalPrecision); // precision
 
-        byte[] valueBytes = DDC.convertBigDecimalToBytes(bdValue, nScale);
-        writeBytes(valueBytes, 0, valueBytes.length);
+        byte[] val = DDC.convertBigDecimalToBytes(bdValue, nScale);
+        writeBytes(val, 0, val.length);
     }
 
     /**
@@ -4937,27 +4932,26 @@ final class TDSWriter {
             // is used, the tdsWriter of the calling preparedStatement is overwritten by the SQLServerResultSet#next()
             // method when fetching new rows.
             // Therefore, we need to send TVP data row by row before fetching new row.
-            if (TVPType.ResultSet == value.tvpType) {
-                if ((null != value.sourceResultSet) && (value.sourceResultSet instanceof SQLServerResultSet)) {
-                    SQLServerResultSet sourceResultSet = (SQLServerResultSet) value.sourceResultSet;
-                    SQLServerStatement src_stmt = (SQLServerStatement) sourceResultSet.getStatement();
-                    int resultSetServerCursorId = sourceResultSet.getServerCursorId();
+            if ((TVPType.ResultSet == value.tvpType)
+                    && ((null != value.sourceResultSet) && (value.sourceResultSet instanceof SQLServerResultSet))) {
+                SQLServerResultSet sourceResultSet = (SQLServerResultSet) value.sourceResultSet;
+                SQLServerStatement src_stmt = (SQLServerStatement) sourceResultSet.getStatement();
+                int resultSetServerCursorId = sourceResultSet.getServerCursorId();
 
-                    if (con.equals(src_stmt.getConnection()) && 0 != resultSetServerCursorId) {
-                        cachedTVPHeaders = ByteBuffer.allocate(stagingBuffer.capacity()).order(stagingBuffer.order());
-                        cachedTVPHeaders.put(stagingBuffer.array(), 0, ((Buffer) stagingBuffer).position());
+                if (con.equals(src_stmt.getConnection()) && 0 != resultSetServerCursorId) {
+                    cachedTVPHeaders = ByteBuffer.allocate(stagingBuffer.capacity()).order(stagingBuffer.order());
+                    cachedTVPHeaders.put(stagingBuffer.array(), 0, ((Buffer) stagingBuffer).position());
 
-                        cachedCommand = this.command;
+                    cachedCommand = this.command;
 
-                        cachedRequestComplete = command.getRequestComplete();
-                        cachedInterruptsEnabled = command.getInterruptsEnabled();
-                        cachedProcessedResponse = command.getProcessedResponse();
+                    cachedRequestComplete = command.getRequestComplete();
+                    cachedInterruptsEnabled = command.getInterruptsEnabled();
+                    cachedProcessedResponse = command.getProcessedResponse();
 
-                        tdsWritterCached = true;
+                    tdsWritterCached = true;
 
-                        if (sourceResultSet.isForwardOnly()) {
-                            sourceResultSet.setFetchSize(1);
-                        }
+                    if (sourceResultSet.isForwardOnly()) {
+                        sourceResultSet.setFetchSize(1);
                     }
                 }
             }
@@ -4995,16 +4989,15 @@ final class TDSWriter {
                     String currentColumnStringValue = null;
 
                     Object currentObject = null;
-                    if (null != rowData) {
-                        // if rowData has value for the current column, retrieve it. If not, current column will stay
-                        // null.
-                        if (rowData.length > currentColumn) {
-                            currentObject = rowData[currentColumn];
-                            if (null != currentObject) {
-                                currentColumnStringValue = String.valueOf(currentObject);
-                            }
+                    // if rowData has value for the current column, retrieve it. If not, current column will stay
+                    // null.
+                    if ((null != rowData) && (rowData.length > currentColumn)) {
+                        currentObject = rowData[currentColumn];
+                        if (null != currentObject) {
+                            currentColumnStringValue = String.valueOf(currentObject);
                         }
                     }
+
                     writeInternalTVPRowValues(jdbcType, currentColumnStringValue, currentObject, columnPair, false);
                     currentColumn++;
                 }
@@ -5122,13 +5115,13 @@ final class TDSWriter {
                      */
                     bdValue = bdValue.setScale(columnPair.getValue().scale, RoundingMode.HALF_UP);
 
-                    byte[] valueBytes = DDC.convertBigDecimalToBytes(bdValue, bdValue.scale());
+                    byte[] val = DDC.convertBigDecimalToBytes(bdValue, bdValue.scale());
 
                     // 1-byte for sign and 16-byte for integer
                     byte[] byteValue = new byte[17];
 
                     // removing the precision and scale information from the valueBytes array
-                    System.arraycopy(valueBytes, 2, byteValue, 0, valueBytes.length - 2);
+                    System.arraycopy(val, 2, byteValue, 0, val.length - 2);
                     writeBytes(byteValue);
                 }
                 break;
@@ -6028,7 +6021,7 @@ final class TDSWriter {
         assert con.isKatmaiOrLater();
 
         assert SSType.DATE == ssType || SSType.TIME == ssType || SSType.DATETIME2 == ssType
-                || SSType.DATETIMEOFFSET == ssType : "Unexpected SSType: " + ssType;
+                || SSType.DATETIMEOFFSET == ssType : UNEXPECTED_SSTYPE + ssType;
 
         // First, for types with a time component, write the scaled nanos since midnight
         if (SSType.TIME == ssType || SSType.DATETIME2 == ssType || SSType.DATETIMEOFFSET == ssType) {
@@ -6063,8 +6056,7 @@ final class TDSWriter {
                 }
                 // If the type is datetime2 or datetimeoffset, truncate only if its the max value supported
                 else {
-                    assert SSType.DATETIME2 == ssType || SSType.DATETIMEOFFSET == ssType : "Unexpected SSType: "
-                            + ssType;
+                    assert SSType.DATETIME2 == ssType || SSType.DATETIMEOFFSET == ssType : UNEXPECTED_SSTYPE + ssType;
 
                     // ... then bump the date, provided that the resulting date is still within
                     // the valid date range.
@@ -6164,7 +6156,7 @@ final class TDSWriter {
         assert con.isKatmaiOrLater();
 
         assert SSType.DATE == ssType || SSType.TIME == ssType || SSType.DATETIME2 == ssType
-                || SSType.DATETIMEOFFSET == ssType : "Unexpected SSType: " + ssType;
+                || SSType.DATETIMEOFFSET == ssType : UNEXPECTED_SSTYPE + ssType;
 
         // store the time and minutesOffset portion of DATETIME2 and DATETIMEOFFSET to be used with date portion
         byte encodedBytesForEncryption[] = null;
@@ -6213,8 +6205,7 @@ final class TDSWriter {
                 }
                 // If the type is datetime2 or datetimeoffset, truncate only if its the max value supported
                 else {
-                    assert SSType.DATETIME2 == ssType || SSType.DATETIMEOFFSET == ssType : "Unexpected SSType: "
-                            + ssType;
+                    assert SSType.DATETIME2 == ssType || SSType.DATETIMEOFFSET == ssType : UNEXPECTED_SSTYPE + ssType;
 
                     // ... then bump the date, provided that the resulting date is still within
                     // the valid date range.
@@ -6303,19 +6294,18 @@ final class TDSWriter {
                 cipherText = SQLServerSecurityUtility.encryptWithKey(encodedBytes, cryptoMeta, con, statement);
             } else if (SSType.DATETIME2 == ssType) {
                 // for Max value, does not round up, do casting instead.
-                if (3652058 == daysIntoCE) { // 9999-12-31
-                    if (864000000000L == scaledNanos) { // 24:00:00 in nanoseconds
-                        // does not round up
-                        scaledNanos = (((long) Nanos.PER_SECOND * secondsSinceMidnight
-                                + getRoundedSubSecondNanos(subSecondNanos)) / divisor) * divisor / 100;
-
-                        int encodedLength = TDS.nanosSinceMidnightLength(TDS.MAX_FRACTIONAL_SECONDS_SCALE);
-                        byte[] encodedNanoBytes = scaledNanosToEncodedBytes(scaledNanos, encodedLength);
-
-                        // for DATETIME2 sends both date and time part together for encryption
-                        encodedBytesForEncryption = new byte[encodedLength + 3];
-                        System.arraycopy(encodedNanoBytes, 0, encodedBytesForEncryption, 0, encodedNanoBytes.length);
-                    }
+                if ((3652058 == daysIntoCE) && // 9999-12-31
+                        (864000000000L == scaledNanos)) { // 24:00:00 in nanoseconds
+                    // does not round up
+                    scaledNanos = (((long) Nanos.PER_SECOND * secondsSinceMidnight
+                            + getRoundedSubSecondNanos(subSecondNanos)) / divisor) * divisor / 100;
+
+                    int encodedLength = TDS.nanosSinceMidnightLength(TDS.MAX_FRACTIONAL_SECONDS_SCALE);
+                    byte[] encodedNanoBytes = scaledNanosToEncodedBytes(scaledNanos, encodedLength);
+
+                    // for DATETIME2 sends both date and time part together for encryption
+                    encodedBytesForEncryption = new byte[encodedLength + 3];
+                    System.arraycopy(encodedNanoBytes, 0, encodedBytesForEncryption, 0, encodedNanoBytes.length);
                 }
 
                 if (encodedBytesForEncryption == null) {
@@ -6331,19 +6321,18 @@ final class TDSWriter {
                         statement);
             } else {
                 // for Max value, does not round up, do casting instead.
-                if (3652058 == daysIntoCE) { // 9999-12-31
-                    if (864000000000L == scaledNanos) { // 24:00:00 in nanoseconds
-                        // does not round up
-                        scaledNanos = (((long) Nanos.PER_SECOND * secondsSinceMidnight
-                                + getRoundedSubSecondNanos(subSecondNanos)) / divisor) * divisor / 100;
-
-                        int encodedLength = TDS.nanosSinceMidnightLength(TDS.MAX_FRACTIONAL_SECONDS_SCALE);
-                        byte[] encodedNanoBytes = scaledNanosToEncodedBytes(scaledNanos, encodedLength);
-
-                        // for DATETIMEOFFSET sends date, time and offset part together for encryption
-                        encodedBytesForEncryption = new byte[encodedLength + 5];
-                        System.arraycopy(encodedNanoBytes, 0, encodedBytesForEncryption, 0, encodedNanoBytes.length);
-                    }
+                if ((3652058 == daysIntoCE) && // 9999-12-31
+                        (864000000000L == scaledNanos)) { // 24:00:00 in nanoseconds
+                    // does not round up
+                    scaledNanos = (((long) Nanos.PER_SECOND * secondsSinceMidnight
+                            + getRoundedSubSecondNanos(subSecondNanos)) / divisor) * divisor / 100;
+
+                    int encodedLength = TDS.nanosSinceMidnightLength(TDS.MAX_FRACTIONAL_SECONDS_SCALE);
+                    byte[] encodedNanoBytes = scaledNanosToEncodedBytes(scaledNanos, encodedLength);
+
+                    // for DATETIMEOFFSET sends date, time and offset part together for encryption
+                    encodedBytesForEncryption = new byte[encodedLength + 5];
+                    System.arraycopy(encodedNanoBytes, 0, encodedBytesForEncryption, 0, encodedNanoBytes.length);
                 }
 
                 if (encodedBytesForEncryption == null) {
@@ -6704,8 +6693,6 @@ final class TDSReader implements Serializable {
     private byte serverSupportedDataClassificationVersion = TDS.DATA_CLASSIFICATION_NOT_ENABLED;
     private final Lock lock = new ReentrantLock();
 
-    private ColumnEncryptionVersion columnEncryptionVersion;
-
     private final byte valueBytes[] = new byte[256];
 
     protected SensitivityClassification sensitivityClassification;
@@ -6729,7 +6716,6 @@ final class TDSReader implements Serializable {
             useColumnEncryption = true;
         }
         serverSupportsColumnEncryption = con.getServerSupportsColumnEncryption();
-        columnEncryptionVersion = con.getServerColumnEncryptionVersion();
         serverSupportsDataClassification = con.getServerSupportsDataClassification();
         serverSupportedDataClassificationVersion = con.getServerSupportedDataClassificationVersion();
     }
@@ -6769,9 +6755,9 @@ final class TDSReader implements Serializable {
      * @return true if additional data is available to be read false if no more data is available
      */
     private boolean ensurePayload() throws SQLServerException {
-        if (payloadOffset == currentPacket.payloadLength)
-            if (!nextPacket())
-                return false;
+        if ((payloadOffset == currentPacket.payloadLength) && (!nextPacket())) {
+            return false;
+        }
         assert payloadOffset < currentPacket.payloadLength;
         return true;
     }
@@ -6837,16 +6823,16 @@ final class TDSReader implements Serializable {
                     + " should be less than numMsgsSent:" + tdsChannel.numMsgsSent;
 
             TDSPacket newPacket = new TDSPacket(con.getTDSPacketSize());
-            if (null != command) {
-                // if cancelQueryTimeout is set, we should wait for the total amount of
-                // queryTimeout + cancelQueryTimeout to
-                // terminate the connection.
-                if ((command.getCancelQueryTimeoutSeconds() > 0 && command.getQueryTimeoutSeconds() > 0)) {
-                    // if a timeout is configured with this object, add it to the timeout poller
-                    int seconds = command.getCancelQueryTimeoutSeconds() + command.getQueryTimeoutSeconds();
-                    this.timeout = con.getSharedTimer().schedule(new TDSTimeoutTask(command, con), seconds);
-                }
+            if ((null != command) &&
+            // if cancelQueryTimeout is set, we should wait for the total amount of
+            // queryTimeout + cancelQueryTimeout to
+            // terminate the connection.
+                    (command.getCancelQueryTimeoutSeconds() > 0 && command.getQueryTimeoutSeconds() > 0)) {
+                // if a timeout is configured with this object, add it to the timeout poller
+                int seconds = command.getCancelQueryTimeoutSeconds() + command.getQueryTimeoutSeconds();
+                this.timeout = con.getSharedTimer().schedule(new TDSTimeoutTask(command, con), seconds);
             }
+
             // First, read the packet header.
             for (int headerBytesRead = 0; headerBytesRead < TDS.PACKET_HEADER_SIZE;) {
                 int bytesRead = tdsChannel.read(newPacket.header, headerBytesRead,
@@ -8148,6 +8134,7 @@ abstract class UninterruptableTDSCommand extends TDSCommand {
         super(logContext, 0, 0);
     }
 
+    @Override
     final void interrupt(String reason) throws SQLServerException {
         // Interrupting an uninterruptable command is a no-op. That is,
         // it can happen, but it should have no effect.
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
index cf707146..6614de23 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerBulkRecord.java
@@ -17,7 +17,7 @@ import java.time.format.DateTimeFormatter;
  * @deprecated as of 8.1.0, because the interface contains methods which are not called as part of actual bulk copy
  *             process. Use {@link ISQLServerBulkData}} instead.
  */
-@Deprecated
+@Deprecated(since = "8.1.0")
 public interface ISQLServerBulkRecord extends ISQLServerBulkData {
     /**
      * Returns whether the column represents an identity column.
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
index 87517e66..ab6d2e32 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerCallableStatement.java
@@ -27,8 +27,10 @@ public interface ISQLServerCallableStatement extends java.sql.CallableStatement,
      * @return the column value; if the value is SQL NULL, the value returned is null
      * @throws SQLServerException
      *         when an error occurs
+     * 
+     * @deprecated
      */
-    @Deprecated
+    @Deprecated(since = "6.5.4")
     BigDecimal getBigDecimal(String parameterName, int scale) throws SQLServerException;
 
     /**
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
index 743ccdc6..e94e8572 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
@@ -409,21 +409,22 @@ public interface ISQLServerConnection extends java.sql.Connection {
     String getIPAddressPreference();
 
     /**
-     * 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.
      *
      * @return Method will always return 0.
+     * @deprecated Time-to-live is no longer supported for the cached Managed Identity tokens.
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     int getMsiTokenCacheTtl();
 
     /**
-     * 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.
      * This method is a no-op for backwards compatibility only.
      *
      * @param timeToLive
      *        Time-to-live is no longer supported.
+     * @deprecated Time-to-live is no longer supported for the cached Managed Identity tokens.
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     void setMsiTokenCacheTtl(int timeToLive);
 }
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
index a9ba172d..63ef16c1 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
@@ -111,11 +111,11 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
     /**
      * Sets the option whether TLS encryption is used.
      * 
-     * @deprecated Use {@link ISQLServerDataSource#setEncrypt(String encryptOption)} instead
      * @param encryptOption
      *        TLS encrypt option. Default is true
+     * @deprecated Use {@link ISQLServerDataSource#setEncrypt(String encryptOption)} instead
      */
-    @Deprecated
+    @Deprecated(since = "10.1.0", forRemoval = true)
     void setEncrypt(boolean encryptOption);
 
     /**
@@ -788,22 +788,23 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
      * Sets the login configuration file for Kerberos authentication. This overrides the default configuration <i>
      * SQLJDBCDriver </i>
      * 
-     * @deprecated Use {@link ISQLServerDataSource#setJAASConfigurationName(String configurationName)} instead
-     * 
      * @param configurationName
      *        the configuration name
+     * @deprecated Use {@link ISQLServerDataSource#setJAASConfigurationName(String configurationName)} instead
+     * 
      */
-    @Deprecated
+    @Deprecated(since = "9.3.0", forRemoval = true)
     void setJASSConfigurationName(String configurationName);
 
     /**
      * Returns the login configuration file for Kerberos authentication.
+     *
      * 
+     * @return login configuration file name
      * @deprecated Use {@link ISQLServerDataSource#getJAASConfigurationName()} instead
      * 
-     * @return login configuration file name
      */
-    @Deprecated
+    @Deprecated(since = "9.3.0", forRemoval = true)
     String getJASSConfigurationName();
 
     /**
@@ -932,24 +933,23 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
     void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert);
 
     /**
-     * This method is deprecated. Use {@link ISQLServerDataSource#setUser(String user)} instead.
-     *
      * Sets the client id to be used to retrieve the access token for a user-assigned Managed Identity.
      * 
      * @param managedIdentityClientId
      *        Client ID of the user-assigned Managed Identity.
+     * @deprecated Use {@link ISQLServerDataSource#setUser(String user)} instead.
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     void setMSIClientId(String managedIdentityClientId);
 
     /**
-     * This method is deprecated. Use {@link ISQLServerDataSource#getUser()} instead.
-     *
      * Returns the value for the connection property 'msiClientId'.
      * 
      * @return msiClientId property value
+     * 
+     * @deprecated Use {@link ISQLServerDataSource#getUser()} instead.
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     String getMSIClientId();
 
     /**
@@ -1123,34 +1123,35 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
     void setSendTemporalDataTypesAsStringForBulkCopy(boolean sendTemporalDataTypesAsStringForBulkCopy);
 
     /**
+     * 
      * Returns the value for the connection property 'AADSecurePrincipalId'.
      * 
-     * @deprecated Use {@link ISQLServerDataSource#getUser()} instead
-     *
      * @return 'AADSecurePrincipalId' property value.
+     * @deprecated Use {@link ISQLServerDataSource#getUser()} instead
      */
-    @Deprecated
+    @Deprecated(since = "9.4.1", forRemoval = true)
     String getAADSecurePrincipalId();
 
     /**
+     *
      * Sets the 'AADSecurePrincipalId' connection property used for Active Directory Service Principal authentication.
      * 
-     * @deprecated Use {@link ISQLServerDataSource#setUser(String user)} instead
      * @param AADSecurePrincipalId
      *        Active Directory Service Principal Id.
+     * @deprecated Use {@link ISQLServerDataSource#setUser(String user)} instead
      */
-    @Deprecated
+    @Deprecated(since = "9.4.1", forRemoval = true)
     void setAADSecurePrincipalId(String AADSecurePrincipalId);
 
     /**
      * Sets the 'AADSecurePrincipalSecret' connection property used for Active Directory Service Principal
      * authentication.
      * 
-     * @deprecated Use {@link ISQLServerDataSource#setPassword(String password)} instead
      * @param AADSecurePrincipalSecret
      *        Active Directory Service Principal secret.
+     * @deprecated Use {@link ISQLServerDataSource#setPassword(String password)} instead
      */
-    @Deprecated
+    @Deprecated(since = "9.4.1", forRemoval = true)
     void setAADSecurePrincipalSecret(String AADSecurePrincipalSecret);
 
     /**
@@ -1214,22 +1215,26 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
     String getPrepareMethod();
 
     /**
-     * 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.
      * This method is a no-op for backwards compatibility only.
      *
      * @param timeToLive
      *        Time-to-live is no longer supported.
+     * 
+     * @deprecated
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     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.
      * This method will always return 0 and is for backwards compatibility only.
      *
      * @return Method will always return 0.
+     * 
+     * @deprecated
      */
-    @Deprecated
+    @Deprecated(since = "12.1.0", forRemoval = true)
     int getMsiTokenCacheTtl();
 
     /**
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerEnclaveProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerEnclaveProvider.java
index 6d57abb1..e5d707a7 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerEnclaveProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerEnclaveProvider.java
@@ -78,9 +78,10 @@ interface ISQLServerEnclaveProvider {
                 }
                 enclaveCEKs.clear();
                 SQLServerAeadAes256CbcHmac256EncryptionKey encryptedKey = new SQLServerAeadAes256CbcHmac256EncryptionKey(
-                        enclaveSession.getSessionSecret(), SQLServerAeadAes256CbcHmac256Algorithm.algorithmName);
+                        enclaveSession.getSessionSecret(),
+                        SQLServerAeadAes256CbcHmac256Algorithm.AEAD_AES_256_CBC_HMAC_SHA256);
                 SQLServerAeadAes256CbcHmac256Algorithm algo = new SQLServerAeadAes256CbcHmac256Algorithm(encryptedKey,
-                        SQLServerEncryptionType.Randomized, (byte) 0x1);
+                        SQLServerEncryptionType.RANDOMIZED, (byte) 0x1);
                 enclavePackage.write(algo.encryptData(keys.toByteArray()));
                 return enclavePackage.toByteArray();
             } catch (GeneralSecurityException | SQLServerException | IOException e) {
@@ -252,7 +253,7 @@ interface ISQLServerEnclaveProvider {
                 }
                 SQLServerEncryptionType encType = SQLServerEncryptionType
                         .of((byte) rs2.getInt(DescribeParameterEncryptionResultSet2.COLUMNENCRYPTIONTYPE.value()));
-                if (SQLServerEncryptionType.PlainText != encType) {
+                if (SQLServerEncryptionType.PLAINTEXT != encType) {
                     params[paramIndex].cryptoMeta = new CryptoMetadata(cekEntry, (short) cekOrdinal,
                             (byte) rs2.getInt(DescribeParameterEncryptionResultSet2.COLUMNENCRYPTIONALGORITHM.value()),
                             null, encType.value,
@@ -439,11 +440,11 @@ abstract class BaseAttestationResponse {
         ByteBuffer enclavePKBuffer = ByteBuffer.wrap(enclavePK).order(ByteOrder.LITTLE_ENDIAN);
         byte[] rsa1 = new byte[4];
         enclavePKBuffer.get(rsa1);
-        int bitCount = enclavePKBuffer.getInt();
+        // bit count unused
         int publicExponentLength = enclavePKBuffer.getInt();
         int publicModulusLength = enclavePKBuffer.getInt();
-        int prime1 = enclavePKBuffer.getInt();
-        int prime2 = enclavePKBuffer.getInt();
+        // prime 1 unused
+        // prime 2 unused
         byte[] exponent = new byte[publicExponentLength];
         enclavePKBuffer.get(exponent);
         byte[] modulus = new byte[publicModulusLength];
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IdleConnectionResiliency.java b/src/main/java/com/microsoft/sqlserver/jdbc/IdleConnectionResiliency.java
index 68a16e2d..35bd85a1 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/IdleConnectionResiliency.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/IdleConnectionResiliency.java
@@ -110,34 +110,32 @@ class IdleConnectionResiliency {
     }
 
     void incrementUnprocessedResponseCount() {
-        if (connection.getRetryCount() > 0 && !isReconnectRunning()) {
-            if (unprocessedResponseCount.incrementAndGet() < 0) {
-                /*
-                 * When this number rolls over, connection recovery is disabled for the rest of the life of the
-                 * connection.
-                 */
-                if (loggerExternal.isLoggable(Level.FINER)) {
-                    loggerExternal.finer("unprocessedResponseCount < 0 on increment. Disabling connection resiliency.");
-                }
-
-                setConnectionRecoveryPossible(false);
+        if ((connection.getRetryCount() > 0 && !isReconnectRunning())
+                && (unprocessedResponseCount.incrementAndGet() < 0)) {
+            /*
+             * When this number rolls over, connection recovery is disabled for the rest of the life of the
+             * connection.
+             */
+            if (loggerExternal.isLoggable(Level.FINER)) {
+                loggerExternal.finer("unprocessedResponseCount < 0 on increment. Disabling connection resiliency.");
             }
+
+            setConnectionRecoveryPossible(false);
         }
     }
 
     void decrementUnprocessedResponseCount() {
-        if (connection.getRetryCount() > 0 && !isReconnectRunning()) {
-            if (unprocessedResponseCount.decrementAndGet() < 0) {
-                /*
-                 * When this number rolls over, connection recovery is disabled for the rest of the life of the
-                 * connection.
-                 */
-                if (loggerExternal.isLoggable(Level.FINER)) {
-                    loggerExternal.finer("unprocessedResponseCount < 0 on decrement. Disabling connection resiliency.");
-                }
-
-                setConnectionRecoveryPossible(false);
+        if ((connection.getRetryCount() > 0 && !isReconnectRunning())
+                && (unprocessedResponseCount.decrementAndGet() < 0)) {
+            /*
+             * When this number rolls over, connection recovery is disabled for the rest of the life of the
+             * connection.
+             */
+            if (loggerExternal.isLoggable(Level.FINER)) {
+                loggerExternal.finer("unprocessedResponseCount < 0 on decrement. Disabling connection resiliency.");
             }
+
+            setConnectionRecoveryPossible(false);
         }
     }
 
@@ -428,6 +426,7 @@ final class ReconnectThread extends Thread {
 
     }
 
+    @Override
     public void run() {
         if (loggerExternal.isLoggable(Level.FINER)) {
             loggerExternal.finer("Starting ReconnectThread for command: " + command.toString());
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultHttpPipelineBuilder.java b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultHttpPipelineBuilder.java
index 51ff4eeb..b635d846 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultHttpPipelineBuilder.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/KeyVaultHttpPipelineBuilder.java
@@ -17,6 +17,7 @@ import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.List;
 
+
 /**
  * The HTTP pipeline builder which includes all the necessary HTTP pipeline policies that will be applied for
  * sending and receiving HTTP requests to the Key Vault service.
@@ -41,20 +42,21 @@ final class KeyVaultHttpPipelineBuilder {
      * Builds the HTTP pipeline with all the necessary HTTP policies included in the pipeline.
      *
      * @return A fully built HTTP pipeline including the default HTTP client.
-     * @throws SQLServerException If the {@link KeyVaultCustomCredentialPolicy} policy cannot be added to the pipeline.
+     * @throws SQLServerException
+     *         If the {@link KeyVaultCustomCredentialPolicy} policy cannot be added to the pipeline.
      */
     HttpPipeline buildPipeline() throws SQLServerException {
         // Closest to API goes first, closest to wire goes last.
-        final List<HttpPipelinePolicy> policies = new ArrayList<>();
+        final List<HttpPipelinePolicy> pol = new ArrayList<>();
 
-        HttpPolicyProviders.addBeforeRetryPolicies(policies);
-        policies.add(retryPolicy);
-        policies.add(new KeyVaultCustomCredentialPolicy(credential));
-        policies.addAll(this.policies);
-        HttpPolicyProviders.addAfterRetryPolicies(policies);
-        policies.add(new HttpLoggingPolicy(httpLogOptions));
+        HttpPolicyProviders.addBeforeRetryPolicies(pol);
+        pol.add(retryPolicy);
+        pol.add(new KeyVaultCustomCredentialPolicy(credential));
+        pol.addAll(this.policies);
+        HttpPolicyProviders.addAfterRetryPolicies(pol);
+        pol.add(new HttpLoggingPolicy(httpLogOptions));
 
-        return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])).build();
+        return new HttpPipelineBuilder().policies(pol.toArray(new HttpPipelinePolicy[0])).build();
     }
 
     /**
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java
index 08746fe6..b0b81ab6 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/PLPInputStream.java
@@ -245,6 +245,7 @@ class PLPInputStream extends BaseInputStream {
      * @exception IOException
      *            if an I/O error occurs.
      */
+    @Override
     public int read(byte[] b, int offset, int maxBytes) throws IOException {
         // If b is null, a NullPointerException is thrown.
         if (null == b)
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
index 0c7a5815..52fc06c9 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
@@ -271,25 +271,22 @@ final class Parameter {
             // otherwise it would be sent as smallint
             // Also, for setters, we are able to send tinyint to smallint
             // However, for output parameter, it might cause error.
-            if (!isOutput()) {
-                if ((JavaType.SHORT == javaType)
-                        && ((JDBCType.TINYINT == jdbcType) || (JDBCType.SMALLINT == jdbcType))) {
-                    // value falls in the TINYINT range
-                    if (((Short) value) >= 0 && ((Short) value) <= 255) {
-                        value = ((Short) value).byteValue();
-                        javaType = JavaType.of(value);
-                        jdbcType = javaType.getJDBCType(SSType.UNKNOWN, jdbcType);
-                    }
-                    // value falls outside tinyint range. Throw an error if the user intends to send as tinyint.
-                    else {
-                        // This is for cases like setObject(1, Short.valueOf("-1"), java.sql.Types.TINYINT);
-                        if (JDBCType.TINYINT == jdbcType) {
-                            MessageFormat form = new MessageFormat(
-                                    SQLServerException.getErrString("R_InvalidDataForAE"));
-                            Object[] msgArgs = {javaType.toString().toLowerCase(Locale.ENGLISH),
-                                    jdbcType.toString().toLowerCase(Locale.ENGLISH)};
-                            throw new SQLServerException(form.format(msgArgs), null);
-                        }
+            if (!isOutput() && ((JavaType.SHORT == javaType)
+                    && ((JDBCType.TINYINT == jdbcType) || (JDBCType.SMALLINT == jdbcType)))) {
+                // value falls in the TINYINT range
+                if (((Short) value) >= 0 && ((Short) value) <= 255) {
+                    value = ((Short) value).byteValue();
+                    javaType = JavaType.of(value);
+                    jdbcType = javaType.getJDBCType(SSType.UNKNOWN, jdbcType);
+                }
+                // value falls outside tinyint range. Throw an error if the user intends to send as tinyint.
+                else {
+                    // This is for cases like setObject(1, Short.valueOf("-1"), java.sql.Types.TINYINT);
+                    if (JDBCType.TINYINT == jdbcType) {
+                        MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidDataForAE"));
+                        Object[] msgArgs = {javaType.toString().toLowerCase(Locale.ENGLISH),
+                                jdbcType.toString().toLowerCase(Locale.ENGLISH)};
+                        throw new SQLServerException(form.format(msgArgs), null);
                     }
                 }
             }
@@ -388,8 +385,8 @@ final class Parameter {
 
     }
 
-    Object getValue(JDBCType jdbcType, InputStreamGetterArgs getterArgs, Calendar cal,
-            TDSReader tdsReader, SQLServerStatement statement) throws SQLServerException {
+    Object getValue(JDBCType jdbcType, InputStreamGetterArgs getterArgs, Calendar cal, TDSReader tdsReader,
+            SQLServerStatement statement) throws SQLServerException {
         if (null == getterDTV)
             getterDTV = new DTV();
 
@@ -505,34 +502,35 @@ final class Parameter {
                             // so, here, if the decimal parameter is encrypted and it is null and it is not outparameter
                             // then we set precision as the default precision instead of max precision
                             if (!isOutput()) {
-                                param.typeDefinition = "decimal(" + SQLServerConnection.defaultDecimalPrecision + ", "
-                                        + scale + ")";
+                                param.typeDefinition = SSType.DECIMAL.toString() + "("
+                                        + SQLServerConnection.defaultDecimalPrecision + "," + scale + ")";
                             }
                         } else {
                             if (SQLServerConnection.defaultDecimalPrecision >= valueLength) {
-                                param.typeDefinition = "decimal(" + SQLServerConnection.defaultDecimalPrecision + ","
-                                        + scale + ")";
+                                param.typeDefinition = SSType.DECIMAL.toString() + "("
+                                        + SQLServerConnection.defaultDecimalPrecision + "," + scale + ")";
 
                                 if (SQLServerConnection.defaultDecimalPrecision < (valueLength + scale)) {
-                                    param.typeDefinition = "decimal("
+                                    param.typeDefinition = SSType.DECIMAL.toString() + "("
                                             + (SQLServerConnection.defaultDecimalPrecision + scale) + "," + scale + ")";
                                 }
                             } else {
-                                param.typeDefinition = "decimal(" + SQLServerConnection.maxDecimalPrecision + ","
-                                        + scale + ")";
+                                param.typeDefinition = SSType.DECIMAL.toString() + "("
+                                        + SQLServerConnection.maxDecimalPrecision + "," + scale + ")";
                             }
                         }
 
                         if (isOutput()) {
-                            param.typeDefinition = "decimal(" + SQLServerConnection.maxDecimalPrecision + ", " + scale
-                                    + ")";
+                            param.typeDefinition = SSType.DECIMAL.toString() + "("
+                                    + SQLServerConnection.maxDecimalPrecision + ", " + scale + ")";
                         }
 
                         if (userProvidesPrecision) {
-                            param.typeDefinition = "decimal(" + valueLength + "," + scale + ")";
+                            param.typeDefinition = SSType.DECIMAL.toString() + "(" + valueLength + "," + scale + ")";
                         }
                     } else
-                        param.typeDefinition = "decimal(" + SQLServerConnection.maxDecimalPrecision + "," + scale + ")";
+                        param.typeDefinition = SSType.DECIMAL.toString() + "(" + SQLServerConnection.maxDecimalPrecision
+                                + "," + scale + ")";
 
                     break;
 
@@ -721,10 +719,10 @@ final class Parameter {
                          */
                         if (0 == valueLength) {
                             // Workaround for the issue when inserting empty string and null into encrypted columns
-                            param.typeDefinition = "varchar(1)";
+                            param.typeDefinition = SSType.VARCHAR.toString() + "(1)";
                             valueLength++;
                         } else {
-                            param.typeDefinition = "varchar(" + valueLength + ")";
+                            param.typeDefinition = SSType.VARCHAR.toString() + "(" + valueLength + ")";
 
                             if (DataTypes.SHORT_VARTYPE_MAX_BYTES <= valueLength) {
                                 param.typeDefinition = VARCHAR_MAX;
@@ -748,12 +746,12 @@ final class Parameter {
                                         || (jdbcTypeSetByUser == JDBCType.LONGVARCHAR))) {
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "varchar(1)";
+                                param.typeDefinition = SSType.VARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else if (DataTypes.SHORT_VARTYPE_MAX_BYTES < valueLength) {
                                 param.typeDefinition = VARCHAR_MAX;
                             } else {
-                                param.typeDefinition = "varchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.VARCHAR.toString() + "(" + valueLength + ")";
                             }
 
                             if (jdbcTypeSetByUser == JDBCType.LONGVARCHAR) {
@@ -763,12 +761,12 @@ final class Parameter {
                                 || jdbcTypeSetByUser == JDBCType.LONGNVARCHAR)) {
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "nvarchar(1)";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else if (DataTypes.SHORT_VARTYPE_MAX_CHARS < valueLength) {
                                 param.typeDefinition = NVARCHAR_MAX;
                             } else {
-                                param.typeDefinition = "nvarchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(" + valueLength + ")";
                             }
 
                             if (jdbcTypeSetByUser == JDBCType.LONGNVARCHAR) {
@@ -777,10 +775,10 @@ final class Parameter {
                         } else { // used if setNull() is called with java.sql.Types.NCHAR
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "nvarchar(1)";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else {
-                                param.typeDefinition = "nvarchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(" + valueLength + ")";
 
                                 if (DataTypes.SHORT_VARTYPE_MAX_BYTES <= valueLength) {
                                     param.typeDefinition = NVARCHAR_MAX;
@@ -817,10 +815,10 @@ final class Parameter {
                                         || (JDBCType.LONGVARCHAR == jdbcTypeSetByUser))) {
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "varchar(1)";
+                                param.typeDefinition = SSType.VARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else {
-                                param.typeDefinition = "varchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.VARCHAR.toString() + "(" + valueLength + ")";
 
                                 if (DataTypes.SHORT_VARTYPE_MAX_BYTES < valueLength) {
                                     param.typeDefinition = VARCHAR_MAX;
@@ -835,10 +833,10 @@ final class Parameter {
                                         || (JDBCType.LONGNVARCHAR == jdbcTypeSetByUser))) {
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "nvarchar(1)";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else {
-                                param.typeDefinition = "nvarchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(" + valueLength + ")";
 
                                 if (DataTypes.SHORT_VARTYPE_MAX_BYTES <= valueLength) {
                                     param.typeDefinition = NVARCHAR_MAX;
@@ -851,10 +849,10 @@ final class Parameter {
                         } else { // used if setNull() is called with java.sql.Types.NCHAR
                             if (0 == valueLength) {
                                 // Workaround for the issue when inserting empty string and null into encrypted columns
-                                param.typeDefinition = "nvarchar(1)";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(1)";
                                 valueLength++;
                             } else {
-                                param.typeDefinition = "nvarchar(" + valueLength + ")";
+                                param.typeDefinition = SSType.NVARCHAR.toString() + "(" + valueLength + ")";
 
                                 if (DataTypes.SHORT_VARTYPE_MAX_BYTES <= valueLength) {
                                     param.typeDefinition = NVARCHAR_MAX;
@@ -1152,7 +1150,7 @@ final class Parameter {
     void sendByRPC(TDSWriter tdsWriter, SQLServerStatement statement) throws SQLServerException {
         assert null != inputDTV : "Parameter was neither set nor registered";
         SQLServerConnection conn = statement.connection;
-        
+
         try {
             inputDTV.sendCryptoMetaData(this.cryptoMeta, tdsWriter);
             inputDTV.setJdbcTypeSetByUser(getJdbcTypeSetByUser(), getValueLength());
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java
index 54df7d76..70ed6a5f 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/ReaderInputStream.java
@@ -72,6 +72,7 @@ class ReaderInputStream extends InputStream {
      * @throws IOException
      *         - if an I/O error occurs
      */
+    @Override
     public int available() throws IOException {
         assert null != reader;
         assert null != encodedChars;
@@ -97,10 +98,12 @@ class ReaderInputStream extends InputStream {
 
     private final byte[] oneByte = new byte[1];
 
+    @Override
     public int read() throws IOException {
         return (-1 == readInternal(oneByte, 0, oneByte.length)) ? -1 : oneByte[0];
     }
 
+    @Override
     public int read(byte[] b) throws IOException {
         return readInternal(b, 0, b.length);
     }
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
index 59ace925..b41531db 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLCollation.java
@@ -511,6 +511,7 @@ final class SQLCollation implements java.io.Serializable {
             this.encoding = encoding;
         }
 
+        @Override
         public final String toString() {
             return name;
         }
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAASEnclaveProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAASEnclaveProvider.java
index b12151ca..99c11638 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAASEnclaveProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAASEnclaveProvider.java
@@ -52,7 +52,9 @@ public class SQLServerAASEnclaveProvider implements ISQLServerEnclaveProvider {
     /**
      * default constructor
      */
-    public SQLServerAASEnclaveProvider() {}
+    public SQLServerAASEnclaveProvider() {
+        // default constructor
+    }
 
     @Override
     public void getAttestationParameters(String url) throws SQLServerException {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java
index becf72a0..55863ba8 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Algorithm.java
@@ -33,7 +33,9 @@ class SQLServerAeadAes256CbcHmac256Algorithm extends SQLServerEncryptionAlgorith
     static final private java.util.logging.Logger aeLogger = java.util.logging.Logger
             .getLogger("com.microsoft.sqlserver.jdbc.SQLServerAeadAes256CbcHmac256Algorithm");
 
-    final static String algorithmName = "AEAD_AES_256_CBC_HMAC_SHA256";
+    final static String AEAD_AES_256_CBC_HMAC_SHA256 = "AEAD_AES_256_CBC_HMAC_SHA256";
+    private static final String HMAC_SHA_256 = "HmacSHA256";
+
     // Stores column encryption key which includes root key and derived keys
     private SQLServerAeadAes256CbcHmac256EncryptionKey columnEncryptionkey;
     private byte algorithmVersion;
@@ -75,7 +77,7 @@ class SQLServerAeadAes256CbcHmac256Algorithm extends SQLServerEncryptionAlgorith
             SQLServerEncryptionType encryptionType, byte algorithmVersion) {
         this.columnEncryptionkey = columnEncryptionkey;
 
-        if (encryptionType == SQLServerEncryptionType.Deterministic) {
+        if (encryptionType == SQLServerEncryptionType.DETERMINISTIC) {
             this.isDeterministic = true;
         }
         this.algorithmVersion = algorithmVersion;
@@ -160,8 +162,8 @@ class SQLServerAeadAes256CbcHmac256Algorithm extends SQLServerEncryptionAlgorith
 
             if (hasAuthenticationTag) {
 
-                Mac hmac = Mac.getInstance("HmacSHA256");
-                SecretKeySpec initkey = new SecretKeySpec(columnEncryptionkey.getMacKey(), "HmacSHA256");
+                Mac hmac = Mac.getInstance(HMAC_SHA_256);
+                SecretKeySpec initkey = new SecretKeySpec(columnEncryptionkey.getMacKey(), HMAC_SHA_256);
                 hmac.init(initkey);
                 hmac.update(version, 0, version.length);
                 hmac.update(iv, 0, iv.length);
@@ -330,8 +332,8 @@ class SQLServerAeadAes256CbcHmac256Algorithm extends SQLServerEncryptionAlgorith
         byte[] computedHash;
         byte[] authenticationTag = new byte[keySizeInBytes];
 
-        Mac hmac = Mac.getInstance("HmacSHA256");
-        SecretKeySpec key = new SecretKeySpec(columnEncryptionkey.getMacKey(), "HmacSHA256");
+        Mac hmac = Mac.getInstance(HMAC_SHA_256);
+        SecretKeySpec key = new SecretKeySpec(columnEncryptionkey.getMacKey(), HMAC_SHA_256);
         hmac.init(key);
         hmac.update(version, 0, version.length);
         hmac.update(iv, 0, iv.length);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java
index 58f5af23..0094551b 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerAeadAes256CbcHmac256Factory.java
@@ -25,11 +25,11 @@ class SQLServerAeadAes256CbcHmac256Factory extends SQLServerEncryptionAlgorithmF
             SQLServerEncryptionType encryptionType, String encryptionAlgorithm) throws SQLServerException {
 
         assert (columnEncryptionKey != null);
-        if (encryptionType != SQLServerEncryptionType.Deterministic
-                && encryptionType != SQLServerEncryptionType.Randomized) {
+        if (encryptionType != SQLServerEncryptionType.DETERMINISTIC
+                && encryptionType != SQLServerEncryptionType.RANDOMIZED) {
             MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidEncryptionType"));
             Object[] msgArgs = {encryptionType, encryptionAlgorithm,
-                    "'" + SQLServerEncryptionType.Deterministic + "," + SQLServerEncryptionType.Randomized + "'"};
+                    "'" + SQLServerEncryptionType.DETERMINISTIC + "," + SQLServerEncryptionType.RANDOMIZED + "'"};
             throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
 
         }
@@ -49,7 +49,8 @@ class SQLServerAeadAes256CbcHmac256Factory extends SQLServerEncryptionAlgorithmF
 
         if (!encryptionAlgorithms.containsKey(factoryKey)) {
             SQLServerAeadAes256CbcHmac256EncryptionKey encryptedKey = new SQLServerAeadAes256CbcHmac256EncryptionKey(
-                    columnEncryptionKey.getRootKey(), SQLServerAeadAes256CbcHmac256Algorithm.algorithmName);
+                    columnEncryptionKey.getRootKey(),
+                    SQLServerAeadAes256CbcHmac256Algorithm.AEAD_AES_256_CBC_HMAC_SHA256);
             aesAlgorithm = new SQLServerAeadAes256CbcHmac256Algorithm(encryptedKey, encryptionType, algorithmVersion);
             encryptionAlgorithms.putIfAbsent(factoryKey, aesAlgorithm);
         }
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
index bf98fd28..d1c13a15 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
@@ -70,6 +70,8 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
      */
     private static final long serialVersionUID = 1989903904654306244L;
 
+    private static final String MAX = "(max)";
+
     /**
      * Represents the column mappings between the source and destination table
      */
@@ -1243,9 +1245,9 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
 
             // if destination is encrypted send metadata from destination and not from source
             if (DataTypes.SHORT_VARTYPE_MAX_BYTES < destPrecision) {
-                return "varbinary(max)";
+                return SSType.VARBINARY.toString() + MAX;
             } else {
-                return "varbinary(" + destColumnMetadata.get(destColIndx).precision + ")";
+                return SSType.VARBINARY.toString() + "(" + destColumnMetadata.get(destColIndx).precision + ")";
             }
         }
 
@@ -1268,7 +1270,7 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
         // SQL Server does not convert string to binary, we will have to explicitly convert before sending.
         if (Util.isCharType(bulkJdbcType) && Util.isBinaryType(destSSType)) {
             if (isStreaming)
-                return "varbinary(max)";
+                return SSType.VARBINARY.toString() + MAX;
             else
                 // Return binary(n) or varbinary(n) or varbinary(max) depending on destination type/precision.
                 return destSSType.toString() + "("
@@ -1277,31 +1279,33 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
 
         switch (bulkJdbcType) {
             case java.sql.Types.INTEGER:
-                return "int";
+                return SSType.INTEGER.toString();
 
             case java.sql.Types.SMALLINT:
-                return "smallint";
+                return SSType.SMALLINT.toString();
 
             case java.sql.Types.BIGINT:
-                return "bigint";
+                return SSType.BIGINT.toString();
 
             case java.sql.Types.BIT:
-                return "bit";
+                return SSType.BIT.toString();
 
             case java.sql.Types.TINYINT:
-                return "tinyint";
+                return SSType.TINYINT.toString();
 
             case java.sql.Types.FLOAT:
             case java.sql.Types.DOUBLE:
-                return "float";
+                return SSType.FLOAT.toString();
 
             case java.sql.Types.REAL:
-                return "real";
+                return SSType.REAL.toString();
 
             case microsoft.sql.Types.MONEY:
-                return "money";
+                return SSType.MONEY.toString();
+
             case microsoft.sql.Types.SMALLMONEY:
-                return "smallmoney";
+                return SSType.SMALLMONEY.toString();
+
             case java.sql.Types.DECIMAL:
                 /*
                  * SQL Server allows the insertion of decimal and numeric into a money (and smallmoney) column, but
@@ -1310,31 +1314,31 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                  * money/smallmoney and the source is decimal/numeric.
                  */
                 if (destSSType == SSType.MONEY) {
-                    return "money";
+                    return SSType.MONEY.toString();
                 } else if (destSSType == SSType.SMALLMONEY) {
-                    return "smallmoney";
+                    return SSType.SMALLMONEY.toString();
                 }
-                return "decimal(" + bulkPrecision + ", " + bulkScale + ")";
+                return SSType.DECIMAL.toString() + "(" + bulkPrecision + ", " + bulkScale + ")";
 
             case java.sql.Types.NUMERIC:
                 if (destSSType == SSType.MONEY) {
-                    return "money";
+                    return SSType.MONEY.toString();
                 } else if (destSSType == SSType.SMALLMONEY) {
-                    return "smallmoney";
+                    return SSType.SMALLMONEY.toString();
                 }
-                return "numeric(" + bulkPrecision + ", " + bulkScale + ")";
+                return SSType.NUMERIC.toString() + "(" + bulkPrecision + ", " + bulkScale + ")";
 
             case microsoft.sql.Types.GUID:
                 // For char the value has to be between 0 to 8000.
-                return "char(" + bulkPrecision + ")";
+                return SSType.CHAR.toString() + "(" + bulkPrecision + ")";
             case java.sql.Types.CHAR:
                 if (unicodeConversionRequired(bulkJdbcType, destSSType)) {
-                    return "nchar(" + bulkPrecision + ")";
+                    return SSType.NCHAR.toString() + "(" + bulkPrecision + ")";
                 } else {
-                    return "char(" + bulkPrecision + ")";
+                    return SSType.CHAR.toString() + "(" + bulkPrecision + ")";
                 }
             case java.sql.Types.NCHAR:
-                return "NCHAR(" + bulkPrecision + ")";
+                return SSType.NCHAR.toString() + "(" + bulkPrecision + ")";
 
             case java.sql.Types.LONGVARCHAR:
             case java.sql.Types.VARCHAR:
@@ -1342,15 +1346,15 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                 // Doesn't need to match with the exact size of data or with the destination column size.
                 if (unicodeConversionRequired(bulkJdbcType, destSSType)) {
                     if (isStreaming) {
-                        return "nvarchar(max)";
+                        return SSType.NVARCHAR.toString() + MAX;
                     } else {
-                        return "nvarchar(" + bulkPrecision + ")";
+                        return SSType.NVARCHAR.toString() + "(" + bulkPrecision + ")";
                     }
                 } else {
                     if (isStreaming) {
-                        return "varchar(max)";
+                        return SSType.VARCHAR.toString() + MAX;
                     } else {
-                        return "varchar(" + bulkPrecision + ")";
+                        return SSType.VARCHAR.toString() + "(" + bulkPrecision + ")";
                     }
                 }
                 // For INSERT BULK operations, XMLTYPE is to be sent as NVARCHAR(N) or NVARCHAR(MAX) data type.
@@ -1358,21 +1362,21 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
             case java.sql.Types.LONGNVARCHAR:
             case java.sql.Types.NVARCHAR:
                 if (isStreaming) {
-                    return "NVARCHAR(MAX)";
+                    return SSType.NVARCHAR.toString() + MAX;
                 } else {
-                    return "NVARCHAR(" + bulkPrecision + ")";
+                    return SSType.NVARCHAR.toString() + "(" + bulkPrecision + ")";
                 }
 
             case java.sql.Types.BINARY:
                 // For binary the value has to be between 0 to 8000.
-                return "binary(" + bulkPrecision + ")";
+                return SSType.BINARY.toString() + "(" + bulkPrecision + ")";
 
             case java.sql.Types.LONGVARBINARY:
             case java.sql.Types.VARBINARY:
                 if (isStreaming)
-                    return "varbinary(max)";
+                    return SSType.VARBINARY.toString() + MAX;
                 else
-                    return "varbinary(" + bulkPrecision + ")";
+                    return SSType.VARBINARY.toString() + "(" + bulkPrecision + ")";
 
             case microsoft.sql.Types.DATETIME:
             case microsoft.sql.Types.SMALLDATETIME:
@@ -1380,19 +1384,19 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                 switch (destSSType) {
                     case SMALLDATETIME:
                         if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                            return "varchar("
+                            return SSType.VARCHAR.toString() + "("
                                     + ((0 == bulkPrecision) ? sourceBulkRecordTemporalMaxPrecision : bulkPrecision)
                                     + ")";
                         } else {
-                            return "smalldatetime";
+                            return SSType.SMALLDATETIME.toString();
                         }
                     case DATETIME:
                         if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                            return "varchar("
+                            return SSType.VARCHAR.toString() + "("
                                     + ((0 == bulkPrecision) ? sourceBulkRecordTemporalMaxPrecision : bulkPrecision)
                                     + ")";
                         } else {
-                            return "datetime";
+                            return SSType.DATETIME.toString();
                         }
                     default:
                         // datetime2
@@ -1403,9 +1407,10 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                          * temporal type.
                          */
                         if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                            return "varchar(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision) + ")";
+                            return SSType.VARCHAR.toString() + "("
+                                    + ((0 == bulkPrecision) ? destPrecision : bulkPrecision) + ")";
                         } else {
-                            return "datetime2(" + bulkScale + ")";
+                            return SSType.DATETIME2.toString() + "(" + bulkScale + ")";
                         }
                 }
 
@@ -1416,9 +1421,10 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                  * conversion. if the source is ResultSet, we send the data as the corresponding temporal type.
                  */
                 if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                    return "varchar(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision) + ")";
+                    return SSType.VARCHAR.toString() + "(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision)
+                            + ")";
                 } else {
-                    return "date";
+                    return SSType.DATE.toString();
                 }
 
             case java.sql.Types.TIME:
@@ -1428,15 +1434,16 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                  * conversion. if the source is ResultSet, we send the data as the corresponding temporal type.
                  */
                 if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                    return "varchar(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision) + ")";
+                    return SSType.VARCHAR.toString() + "(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision)
+                            + ")";
                 } else {
-                    return "time(" + bulkScale + ")";
+                    return SSType.TIME.toString() + "(" + bulkScale + ")";
                 }
 
                 // Return DATETIMEOFFSET for TIME_WITH_TIMEZONE and TIMESTAMP_WITH_TIMEZONE
             case 2013: // java.sql.Types.TIME_WITH_TIMEZONE
             case 2014: // java.sql.Types.TIMESTAMP_WITH_TIMEZONE
-                return "datetimeoffset(" + bulkScale + ")";
+                return SSType.DATETIMEOFFSET.toString() + "(" + bulkScale + ")";
 
             case microsoft.sql.Types.DATETIMEOFFSET:
                 /*
@@ -1445,12 +1452,13 @@ public class SQLServerBulkCopy implements java.lang.AutoCloseable, java.io.Seria
                  * conversion. if the source is ResultSet, we send the data as the corresponding temporal type.
                  */
                 if (null != serverBulkData && connection.getSendTemporalDataTypesAsStringForBulkCopy()) {
-                    return "varchar(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision) + ")";
+                    return SSType.VARCHAR.toString() + "(" + ((0 == bulkPrecision) ? destPrecision : bulkPrecision)
+                            + ")";
                 } else {
-                    return "datetimeoffset(" + bulkScale + ")";
+                    return SSType.DATETIMEOFFSET.toString() + "(" + bulkScale + ")";
                 }
             case microsoft.sql.Types.SQL_VARIANT:
-                return "sql_variant";
+                return SSType.SQL_VARIANT.toString();
             default: {
                 MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_BulkTypeNotSupported"));
                 Object[] msgArgs = {JDBCType.of(bulkJdbcType).toString().toLowerCase(Locale.ENGLISH)};
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
index 4308b080..0c3d5538 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java
@@ -49,6 +49,9 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
      */
     private static final long serialVersionUID = 5044984771674532350L;
 
+    private static final String GET_TIMESTAMP = "getTimestamp";
+    private static final String SQLSTATE_07009 = "07009";
+
     /** the call param names */
     private HashMap<String, Integer> parameterNames;
 
@@ -409,7 +412,7 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
         if (index < 1 || index > inOutParam.length) {
             MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidOutputParameter"));
             Object[] msgArgs = {index};
-            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), "07009", false);
+            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), SQLSTATE_07009, false);
         }
 
         // Check index refers to a registered OUT parameter
@@ -417,13 +420,13 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
             MessageFormat form = new MessageFormat(
                     SQLServerException.getErrString("R_outputParameterNotRegisteredForOutput"));
             Object[] msgArgs = {index};
-            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), "07009", true);
+            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), SQLSTATE_07009, true);
         }
 
         // If we haven't executed the statement yet then throw a nice friendly exception.
         if (!wasExecuted())
             SQLServerException.makeFromDriverError(connection, this,
-                    SQLServerException.getErrString("R_statementMustBeExecuted"), "07009", false);
+                    SQLServerException.getErrString("R_statementMustBeExecuted"), SQLSTATE_07009, false);
 
         resultsReader().getCommand().checkForInterrupt();
 
@@ -892,39 +895,39 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
     @Override
     public Timestamp getTimestamp(int index) throws SQLServerException {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
-            loggerExternal.entering(getClassNameLogging(), "getTimestamp", index);
+            loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, index);
         checkClosed();
         java.sql.Timestamp value = (java.sql.Timestamp) getValue(index, JDBCType.TIMESTAMP);
-        loggerExternal.exiting(getClassNameLogging(), "getTimestamp", value);
+        loggerExternal.exiting(getClassNameLogging(), GET_TIMESTAMP, value);
         return value;
     }
 
     @Override
     public Timestamp getTimestamp(String parameterName) throws SQLServerException {
-        loggerExternal.entering(getClassNameLogging(), "getTimestamp", parameterName);
+        loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, parameterName);
         checkClosed();
         java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(parameterName), JDBCType.TIMESTAMP);
-        loggerExternal.exiting(getClassNameLogging(), "getTimestamp", value);
+        loggerExternal.exiting(getClassNameLogging(), GET_TIMESTAMP, value);
         return value;
     }
 
     @Override
     public Timestamp getTimestamp(int index, Calendar cal) throws SQLServerException {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
-            loggerExternal.entering(getClassNameLogging(), "getTimestamp", new Object[] {index, cal});
+            loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, new Object[] {index, cal});
         checkClosed();
         java.sql.Timestamp value = (java.sql.Timestamp) getValue(index, JDBCType.TIMESTAMP, cal);
-        loggerExternal.exiting(getClassNameLogging(), "getTimestamp", value);
+        loggerExternal.exiting(getClassNameLogging(), GET_TIMESTAMP, value);
         return value;
     }
 
     @Override
     public Timestamp getTimestamp(String name, Calendar cal) throws SQLServerException {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
-            loggerExternal.entering(getClassNameLogging(), "getTimestamp", new Object[] {name, cal});
+            loggerExternal.entering(getClassNameLogging(), GET_TIMESTAMP, new Object[] {name, cal});
         checkClosed();
         java.sql.Timestamp value = (java.sql.Timestamp) getValue(findColumn(name), JDBCType.TIMESTAMP, cal);
-        loggerExternal.exiting(getClassNameLogging(), "getTimestamp", value);
+        loggerExternal.exiting(getClassNameLogging(), GET_TIMESTAMP, value);
         return value;
     }
 
@@ -1329,7 +1332,8 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
                     MessageFormat form = new MessageFormat(
                             SQLServerException.getErrString("R_parameterNotDefinedForProcedure"));
                     Object[] msgArgs = {columnName, ""};
-                    SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), "07009", false);
+                    SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), SQLSTATE_07009,
+                            false);
                 }
 
                 try (ResultSet rs = s.executeQueryInternal(metaQuery.toString())) {
@@ -1373,7 +1377,7 @@ public class SQLServerCallableStatement extends SQLServerPreparedStatement imple
             MessageFormat form = new MessageFormat(
                     SQLServerException.getErrString("R_parameterNotDefinedForProcedure"));
             Object[] msgArgs = {columnName, procedureName};
-            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), "07009", false);
+            SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), SQLSTATE_07009, false);
         }
 
         // @RETURN_VALUE is always in the list. If the user uses return value ?=call(@p1) syntax then
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
index 53d58b8c..03ee9820 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionAzureKeyVaultProvider.java
@@ -129,6 +129,7 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
     private static final String MSSQL_JDBC_PROPERTIES = "mssql-jdbc.properties";
     private static final String AKV_TRUSTED_ENDPOINTS_KEYWORD = "AKVTrustedEndpoints";
     private static final String RSA_ENCRYPTION_ALGORITHM_WITH_OAEP_FOR_AKV = "RSA-OAEP";
+    private static final String SHA_256 = "SHA-256";
 
     private static final List<String> akvTrustedEndpoints = getTrustedEndpoints();
 
@@ -412,7 +413,7 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
 
         MessageDigest md = null;
         try {
-            md = MessageDigest.getInstance("SHA-256");
+            md = MessageDigest.getInstance(SHA_256);
         } catch (NoSuchAlgorithmException e) {
             throw new SQLServerException(SQLServerException.getErrString("R_NoSHA256Algorithm"), e);
         }
@@ -533,7 +534,7 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
 
         MessageDigest md = null;
         try {
-            md = MessageDigest.getInstance("SHA-256");
+            md = MessageDigest.getInstance(SHA_256);
         } catch (NoSuchAlgorithmException e) {
             throw new SQLServerException(SQLServerException.getErrString("R_NoSHA256Algorithm"), e);
         }
@@ -874,7 +875,7 @@ public class SQLServerColumnEncryptionAzureKeyVaultProvider extends SQLServerCol
         }
 
         try {
-            MessageDigest md = MessageDigest.getInstance("SHA-256");
+            MessageDigest md = MessageDigest.getInstance(SHA_256);
             md.update(name.toLowerCase().getBytes(java.nio.charset.StandardCharsets.UTF_16LE));
             md.update(masterKeyPath.toLowerCase().getBytes(java.nio.charset.StandardCharsets.UTF_16LE));
             // value of allowEnclaveComputations is always true here
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
index 039625f0..eb4992c6 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
@@ -622,6 +622,10 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     private static final String CALL_ABORT_PERM = "callAbort";
 
     private static final String SET_NETWORK_TIMEOUT_PERM = "setNetworkTimeout";
+    private static final String SET_SAVE_POINT = "setSaveoint";
+    private static final String CREATE_STATEMENT = "createStatement";
+    private static final String ACTIVITY_ID = " ActivityId: ";
+    private static final String TRUSTED_KEY_MASTER_PATHS = "Trusted Master Key Paths";
 
     /** see connection properties doc (default is false) */
     private boolean sendStringParametersAsUnicode = SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE
@@ -1229,7 +1233,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
      */
     public static void setColumnEncryptionTrustedMasterKeyPaths(Map<String, List<String>> trustedKeyPaths) {
         loggerExternal.entering(loggingClassNameBase, "setColumnEncryptionTrustedMasterKeyPaths",
-                "Setting Trusted Master Key Paths");
+                "Setting " + TRUSTED_KEY_MASTER_PATHS);
 
         sLock.lock();
         try {
@@ -1243,7 +1247,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         }
 
         loggerExternal.exiting(loggingClassNameBase, "setColumnEncryptionTrustedMasterKeyPaths",
-                "Number of Trusted Master Key Paths: " + columnEncryptionTrustedMasterKeyPaths.size());
+                "Number of " + TRUSTED_KEY_MASTER_PATHS + ": " + columnEncryptionTrustedMasterKeyPaths.size());
     }
 
     /**
@@ -1256,7 +1260,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
      */
     public static void updateColumnEncryptionTrustedMasterKeyPaths(String server, List<String> trustedKeyPaths) {
         loggerExternal.entering(loggingClassNameBase, "updateColumnEncryptionTrustedMasterKeyPaths",
-                "Updating Trusted Master Key Paths");
+                "Updating " + TRUSTED_KEY_MASTER_PATHS);
 
         sLock.lock();
         try {
@@ -1267,7 +1271,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         }
 
         loggerExternal.exiting(loggingClassNameBase, "updateColumnEncryptionTrustedMasterKeyPaths",
-                "Number of Trusted Master Key Paths: " + columnEncryptionTrustedMasterKeyPaths.size());
+                "Number of " + TRUSTED_KEY_MASTER_PATHS + ": " + columnEncryptionTrustedMasterKeyPaths.size());
     }
 
     /**
@@ -1278,7 +1282,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
      */
     public static void removeColumnEncryptionTrustedMasterKeyPaths(String server) {
         loggerExternal.entering(loggingClassNameBase, "removeColumnEncryptionTrustedMasterKeyPaths",
-                "Removing Trusted Master Key Paths");
+                "Removing " + TRUSTED_KEY_MASTER_PATHS);
 
         sLock.lock();
         try {
@@ -1289,7 +1293,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         }
 
         loggerExternal.exiting(loggingClassNameBase, "removeColumnEncryptionTrustedMasterKeyPaths",
-                "Number of Trusted Master Key Paths: " + columnEncryptionTrustedMasterKeyPaths.size());
+                "Number of " + TRUSTED_KEY_MASTER_PATHS + ": " + columnEncryptionTrustedMasterKeyPaths.size());
     }
 
     /**
@@ -1299,7 +1303,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
      */
     public static Map<String, List<String>> getColumnEncryptionTrustedMasterKeyPaths() {
         loggerExternal.entering(loggingClassNameBase, "getColumnEncryptionTrustedMasterKeyPaths",
-                "Getting Trusted Master Key Paths");
+                "Getting " + TRUSTED_KEY_MASTER_PATHS);
 
         sLock.lock();
         try {
@@ -1310,7 +1314,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
             }
 
             loggerExternal.exiting(loggingClassNameBase, "getColumnEncryptionTrustedMasterKeyPaths",
-                    "Number of Trusted Master Key Paths: " + masterKeyPathCopy.size());
+                    "Number of " + TRUSTED_KEY_MASTER_PATHS + ": " + masterKeyPathCopy.size());
 
             return masterKeyPathCopy;
         } finally {
@@ -1423,7 +1427,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         // assert limit >= 0;
         if (maxFieldSize != limit) {
             if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
             // If no limit on field size, set text size to max (2147483647), NOT default (0 --> 4K)
             connectionCommand("SET TEXTSIZE " + ((0 == limit) ? Integer.MAX_VALUE : limit), "setMaxFieldSize");
@@ -1455,7 +1459,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         // assert limit >= 0;
         if (maxRows != limit) {
             if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
             connectionCommand("SET ROWCOUNT " + limit, "setMaxRows");
             maxRows = limit;
@@ -2971,7 +2975,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         } else {
             if (isDBMirroring) {
                 // Create a temporary class with the mirror info from the user
-                tempFailover = new FailoverInfo(mirror, this, false);
+                tempFailover = new FailoverInfo(mirror, false);
             }
         }
 
@@ -3236,7 +3240,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
             }
 
             if (null == tempFailover)
-                tempFailover = new FailoverInfo(failoverPartnerServerProvided, this, false);
+                tempFailover = new FailoverInfo(failoverPartnerServerProvided, false);
             // if the failover is not from the map already out this in the map, if it is from the map just make sure
             // that we change the
             if (null != foActual) {
@@ -4243,9 +4247,9 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
 
     @Override
     public Statement createStatement() throws SQLServerException {
-        loggerExternal.entering(loggingClassName, "createStatement");
+        loggerExternal.entering(loggingClassName, CREATE_STATEMENT);
         Statement st = createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
-        loggerExternal.exiting(loggingClassName, "createStatement", st);
+        loggerExternal.exiting(loggingClassName, CREATE_STATEMENT, st);
         return st;
     }
 
@@ -4278,7 +4282,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         if (loggerExternal.isLoggable(Level.FINER)) {
             loggerExternal.entering(loggingClassName, "setAutoCommit", newAutoCommitMode);
             if (Util.isActivityTraceOn())
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         String commitPendingTransaction = "";
         checkClosed();
@@ -4334,7 +4338,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     public void commit(boolean delayedDurability) throws SQLServerException {
         loggerExternal.entering(loggingClassName, "commit");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         checkClosed();
@@ -4352,7 +4356,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     public void rollback() throws SQLServerException {
         loggerExternal.entering(loggingClassName, "rollback");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
 
@@ -4512,7 +4516,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     public void setCatalog(String catalog) throws SQLServerException {
         loggerExternal.entering(loggingClassName, "setCatalog", catalog);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         if (catalog != null) {
@@ -4535,7 +4539,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         if (loggerExternal.isLoggable(Level.FINER)) {
             loggerExternal.entering(loggingClassName, "setTransactionIsolation", level);
             if (Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
         }
 
@@ -4607,7 +4611,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     @Override
     public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLServerException {
         if (loggerExternal.isLoggable(Level.FINER))
-            loggerExternal.entering(loggingClassName, "createStatement",
+            loggerExternal.entering(loggingClassName, CREATE_STATEMENT,
                     new Object[] {resultSetType, resultSetConcurrency});
         checkClosed();
         SQLServerStatement st = new SQLServerStatement(this, resultSetType, resultSetConcurrency,
@@ -4615,7 +4619,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         if (requestStarted) {
             addOpenStatement(st);
         }
-        loggerExternal.exiting(loggingClassName, "createStatement", st);
+        loggerExternal.exiting(loggingClassName, CREATE_STATEMENT, st);
         return st;
     }
 
@@ -6513,18 +6517,18 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
 
     @Override
     public Statement createStatement(int nType, int nConcur, int resultSetHoldability) throws SQLServerException {
-        loggerExternal.entering(loggingClassName, "createStatement",
+        loggerExternal.entering(loggingClassName, CREATE_STATEMENT,
                 new Object[] {nType, nConcur, resultSetHoldability});
         Statement st = createStatement(nType, nConcur, resultSetHoldability,
                 SQLServerStatementColumnEncryptionSetting.UseConnectionSetting);
-        loggerExternal.exiting(loggingClassName, "createStatement", st);
+        loggerExternal.exiting(loggingClassName, CREATE_STATEMENT, st);
         return st;
     }
 
     @Override
     public Statement createStatement(int nType, int nConcur, int resultSetHoldability,
             SQLServerStatementColumnEncryptionSetting stmtColEncSetting) throws SQLServerException {
-        loggerExternal.entering(loggingClassName, "createStatement",
+        loggerExternal.entering(loggingClassName, CREATE_STATEMENT,
                 new Object[] {nType, nConcur, resultSetHoldability, stmtColEncSetting});
         checkClosed();
         checkValidHoldability(resultSetHoldability);
@@ -6533,7 +6537,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         if (requestStarted) {
             addOpenStatement((ISQLServerStatement) st);
         }
-        loggerExternal.exiting(loggingClassName, "createStatement", st);
+        loggerExternal.exiting(loggingClassName, CREATE_STATEMENT, st);
         return st;
     }
 
@@ -6709,32 +6713,32 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         // than just the outer transaction (@@TRANCOUNT = 1). Should this limitation ever
         // change, the T-SQL below should still work.
         connectionCommand("IF @@TRANCOUNT = 0 BEGIN BEGIN TRAN IF @@TRANCOUNT = 2 COMMIT TRAN END SAVE TRAN "
-                + Util.escapeSQLId(s.getLabel()), "setSavepoint");
+                + Util.escapeSQLId(s.getLabel()), SET_SAVE_POINT);
 
         return s;
     }
 
     @Override
     public Savepoint setSavepoint(String sName) throws SQLServerException {
-        loggerExternal.entering(loggingClassName, "setSavepoint", sName);
+        loggerExternal.entering(loggingClassName, SET_SAVE_POINT, sName);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         Savepoint pt = setNamedSavepoint(sName);
-        loggerExternal.exiting(loggingClassName, "setSavepoint", pt);
+        loggerExternal.exiting(loggingClassName, SET_SAVE_POINT, pt);
         return pt;
     }
 
     @Override
     public Savepoint setSavepoint() throws SQLServerException {
-        loggerExternal.entering(loggingClassName, "setSavepoint");
+        loggerExternal.entering(loggingClassName, SET_SAVE_POINT);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         Savepoint pt = setNamedSavepoint(null);
-        loggerExternal.exiting(loggingClassName, "setSavepoint", pt);
+        loggerExternal.exiting(loggingClassName, SET_SAVE_POINT, pt);
         return pt;
     }
 
@@ -6742,7 +6746,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
     public void rollback(Savepoint s) throws SQLServerException {
         loggerExternal.entering(loggingClassName, "rollback", s);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         if (databaseAutoCommitMode) {
@@ -6767,7 +6771,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
         loggerExternal.entering(loggingClassName, "setHoldability", holdability);
 
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkValidHoldability(holdability);
         checkClosed();
@@ -6835,7 +6839,7 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
             terminate(SQLServerException.DRIVER_ERROR_IO_FAILED, ioe.getMessage(), ioe);
         }
 
-        loggerExternal.exiting(loggingClassName, "setNetworkTimeout");
+        loggerExternal.exiting(loggingClassName, SET_NETWORK_TIMEOUT_PERM);
     }
 
     @Override
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
index a6c928a9..43a83cb1 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionPoolDataSource.java
@@ -24,7 +24,9 @@ public class SQLServerConnectionPoolDataSource extends SQLServerDataSource imple
     /**
      * default constructor
      */
-    public SQLServerConnectionPoolDataSource() {}
+    public SQLServerConnectionPoolDataSource() {
+        // default constructor
+    }
 
     // Get a new physical connection that the pool manager will issue logical connections from
     @Override
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java
index d2565c82..87b50aeb 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSource.java
@@ -33,6 +33,8 @@ public class SQLServerDataSource
     static final private java.util.logging.Logger parentLogger = java.util.logging.Logger
             .getLogger("com.microsoft.sqlserver.jdbc");
 
+    static final String TRUSTSTORE_PASSWORD_STRIPPED = "trustStorePasswordStripped";
+
     /** logging class name */
     final private String loggingClassName;
 
@@ -1457,7 +1459,7 @@ public class SQLServerDataSource
             ref.add(new StringRefAddr("class", dataSourceClassString));
 
         if (trustStorePasswordStripped)
-            ref.add(new StringRefAddr("trustStorePasswordStripped", "true"));
+            ref.add(new StringRefAddr(TRUSTSTORE_PASSWORD_STRIPPED, "true"));
 
         // Add each property name+value pair found in connectionProps.
         Enumeration<?> e = connectionProps.keys();
@@ -1469,7 +1471,7 @@ public class SQLServerDataSource
                 // The property set and the variable set at the same time is not
                 // possible
                 assert !trustStorePasswordStripped;
-                ref.add(new StringRefAddr("trustStorePasswordStripped", "true"));
+                ref.add(new StringRefAddr(TRUSTSTORE_PASSWORD_STRIPPED, "true"));
             } else {
                 // do not add passwords to the collection. we have normal
                 // password
@@ -1509,7 +1511,7 @@ public class SQLServerDataSource
                 dataSourceURL = propertyValue;
             } else if ("dataSourceDescription".equals(propertyName)) {
                 dataSourceDescription = propertyValue;
-            } else if ("trustStorePasswordStripped".equals(propertyName)) {
+            } else if (TRUSTSTORE_PASSWORD_STRIPPED.equals(propertyName)) {
                 trustStorePasswordStripped = true;
             }
             // Just skip "class" StringRefAddr, it does not go into
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java
index 59fc884b..c1b31512 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDataSourceObjectFactory.java
@@ -24,7 +24,9 @@ public final class SQLServerDataSourceObjectFactory implements ObjectFactory {
     /**
      * Constructs a SQLServerDataSourceObjectFactory.
      */
-    public SQLServerDataSourceObjectFactory() {}
+    public SQLServerDataSourceObjectFactory() {
+        // default constructor
+    }
 
     /**
      * Returns an reference to the SQLServerDataSource instance getObjectInstance is a factory for rehydrating
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
index 8e257ca5..dd474fc4 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java
@@ -270,6 +270,8 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
 
     private static final String IS_GENERATEDCOLUMN = "IS_GENERATEDCOLUMN";
     private static final String IS_AUTOINCREMENT = "IS_AUTOINCREMENT";
+    private static final String ACTIVITY_ID = " ActivityId: ";
+
     private static final String SQL_KEYWORDS = createSqlKeyWords();
 
     // Use LinkedHashMap to force retrieve elements in order they were inserted
@@ -475,16 +477,12 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getCatalogs() throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         // Return the original case instead of CAPS.removed Upper().
-        String s = "SELECT name AS TABLE_CAT FROM sys.databases order by name"; // Need
-                                                                                // to
-                                                                                // match
-                                                                                // case
-                                                                                // of
-                                                                                // connection.getCatalog
+        // Need to match case of connection.getCatalog
+        String s = "SELECT name AS TABLE_CAT FROM sys.databases order by name";
         return getResultSetFromInternalQueries(null, s);
     }
 
@@ -508,7 +506,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table,
             String col) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         // column_privileges supports columns being escaped.
@@ -534,7 +532,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getTables(String catalog, String schema, String table,
             String types[]) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
 
@@ -628,7 +626,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getColumns(String catalog, String schema, String table, String col) throws SQLException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         String originalCatalog = switchCatalogs(catalog);
@@ -805,8 +803,8 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
                 if (null == o) {
                     sb.append("NULL");
                 } else if (o instanceof Number) {
-                    if ("IS_AUTOINCREMENT".equalsIgnoreCase(p.getValue())
-                            || "IS_GENERATEDCOLUMN".equalsIgnoreCase(p.getValue())) {
+                    if (IS_AUTOINCREMENT.equalsIgnoreCase(p.getValue())
+                            || IS_GENERATEDCOLUMN.equalsIgnoreCase(p.getValue())) {
                         sb.append("'").append(Util.escapeSingleQuotes(Util.zeroOneToYesNo(((Number) o).intValue())))
                                 .append("'");
                     } else {
@@ -927,7 +925,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope,
             boolean nullable) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         /*
@@ -965,7 +963,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getCrossReference(String cat1, String schem1, String tab1, String cat2, String schem2,
             String tab2) throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
 
@@ -1151,7 +1149,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getIndexInfo(String cat, String schema, String table, boolean unique,
             boolean approximate) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         /*
@@ -1334,7 +1332,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getPrimaryKeys(String cat, String schema,
             String table) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         /*
@@ -1357,7 +1355,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getProcedureColumns(String catalog, String schema, String proc,
             String col) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         /*
@@ -1401,7 +1399,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getProcedures(String catalog, String schema,
             String proc) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         checkClosed();
@@ -1427,7 +1425,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern,
             String columnNamePattern) throws SQLException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         checkClosed();
@@ -1454,7 +1452,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getSchemas() throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         return getSchemasInternal(null, null);
@@ -1534,7 +1532,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         return getSchemasInternal(catalog, schemaPattern);
     }
@@ -1600,7 +1598,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getTablePrivileges(String catalog, String schema,
             String table) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         table = EscapeIDName(table);
@@ -1621,7 +1619,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getTableTypes() throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         String s = "SELECT 'VIEW' 'TABLE_TYPE' UNION SELECT 'TABLE' UNION SELECT 'SYSTEM TABLE'";
@@ -1638,7 +1636,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public java.sql.ResultSet getTypeInfo() throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
 
@@ -1724,7 +1722,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     @Override
     public String getUserName() throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         String result = "";
@@ -1746,7 +1744,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getVersionColumns(String catalog, String schema,
             String table) throws SQLServerException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         /*
@@ -2385,7 +2383,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public java.sql.ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern,
             int[] types) throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         return getResultSetFromInternalQueries(catalog, "SELECT" +
@@ -2487,7 +2485,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern,
             String attributeNamePattern) throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         return getResultSetFromInternalQueries(catalog, "SELECT" +
@@ -2518,7 +2516,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public ResultSet getSuperTables(String catalog, String schemaPattern,
             String tableNamePattern) throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         return getResultSetFromInternalQueries(catalog, "SELECT" +
@@ -2532,7 +2530,7 @@ public final class SQLServerDatabaseMetaData implements java.sql.DatabaseMetaDat
     public ResultSet getSuperTypes(String catalog, String schemaPattern,
             String typeNamePattern) throws SQLException, SQLTimeoutException {
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         return getResultSetFromInternalQueries(catalog, "SELECT" +
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java
index 9e8f35f6..5c2ba428 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionAlgorithmFactoryList.java
@@ -20,7 +20,7 @@ final class SQLServerEncryptionAlgorithmFactoryList {
 
     private SQLServerEncryptionAlgorithmFactoryList() {
         encryptionAlgoFactoryMap = new ConcurrentHashMap<>();
-        encryptionAlgoFactoryMap.putIfAbsent(SQLServerAeadAes256CbcHmac256Algorithm.algorithmName,
+        encryptionAlgoFactoryMap.putIfAbsent(SQLServerAeadAes256CbcHmac256Algorithm.AEAD_AES_256_CBC_HMAC_SHA256,
                 new SQLServerAeadAes256CbcHmac256Factory());
     }
 
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java
index 289215db..098c9314 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerEncryptionType.java
@@ -14,9 +14,9 @@ import java.text.MessageFormat;
  *
  */
 enum SQLServerEncryptionType {
-    Deterministic((byte) 1),
-    Randomized((byte) 2),
-    PlainText((byte) 0);
+    DETERMINISTIC((byte) 1),
+    RANDOMIZED((byte) 2),
+    PLAINTEXT((byte) 0);
 
     final byte value;
     private static final SQLServerEncryptionType[] VALUES = values();
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
index 29f7d9cf..e7627617 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerException.java
@@ -59,6 +59,7 @@ public final class SQLServerException extends java.sql.SQLException {
     static final String EXCEPTION_XOPEN_CONNECTION_CANT_ESTABLISH = "08001";
     static final String EXCEPTION_XOPEN_CONNECTION_DOES_NOT_EXIST = "08003";
     static final String EXCEPTION_XOPEN_CONNECTION_FAILURE = "08006"; // After connection was connected OK
+
     static final String LOG_CLIENT_CONNECTION_ID_PREFIX = " ClientConnectionId:";
 
     // SQL error values (from sqlerrorcodes.h)
@@ -338,9 +339,9 @@ public final class SQLServerException extends java.sql.SQLException {
         if (xopenStates) {
             switch (errNum) {
                 case 4060:
-                    return "08001"; // Database name undefined at logging
+                    return EXCEPTION_XOPEN_CONNECTION_CANT_ESTABLISH; // Database name undefined at logging
                 case 18456:
-                    return "08001"; // username password wrong at login
+                    return EXCEPTION_XOPEN_CONNECTION_CANT_ESTABLISH; // username password wrong at login
                 case 2714:
                     return "42S01"; // Table already exists
                 case 208:
@@ -353,13 +354,13 @@ public final class SQLServerException extends java.sql.SQLException {
             // The error code came from the db but XOPEN does not have a specific case for it.
         } else {
             switch (errNum) {
-                // case 18456: return "08001"; //username password wrong at login
+                // case 18456: return EXCEPTION_XOPEN_CONNECTION_CANT_ESTABLISH; //username password wrong at login
                 case 8152:
                     return "22001"; // String data right truncation
                 case 515: // 2.2705
                 case 547:
-                    return "23000"; // Integrity constraint violation
                 case 2601:
+                case 2627:
                     return "23000"; // Integrity constraint violation
                 case 2714:
                     return "S0001"; // table already exists
@@ -367,8 +368,6 @@ public final class SQLServerException extends java.sql.SQLException {
                     return "S0002"; // table not found
                 case 1205:
                     return "40001"; // deadlock detected
-                case 2627:
-                    return "23000"; // DPM 4.04. Primary key violation
                 default: {
                     String dbState = databaseState.toString();
                     /*
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMSAL4JUtils.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMSAL4JUtils.java
index 5ec6d09d..cf2b8d6b 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMSAL4JUtils.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMSAL4JUtils.java
@@ -41,6 +41,7 @@ class SQLServerMSAL4JUtils {
 
     static final String REDIRECTURI = "http://localhost";
     static final String SLASH_DEFAULT = "/.default";
+    static final String ACCESS_TOKEN_EXPIRE = " Access token expires on the following date: ";
 
     private static final java.util.logging.Logger logger = java.util.logging.Logger
             .getLogger("com.microsoft.sqlserver.jdbc.SQLServerMSAL4JUtils");
@@ -60,8 +61,7 @@ class SQLServerMSAL4JUtils {
             final IAuthenticationResult authenticationResult = future.get();
 
             if (logger.isLoggable(Level.FINEST)) {
-                logger.finest(logger.toString() + " Access token expires on the following date: "
-                        + authenticationResult.expiresOnDate());
+                logger.finest(logger.toString() + ACCESS_TOKEN_EXPIRE + authenticationResult.expiresOnDate());
             }
 
             return new SqlAuthenticationToken(authenticationResult.accessToken(), authenticationResult.expiresOnDate());
@@ -95,8 +95,7 @@ class SQLServerMSAL4JUtils {
             final IAuthenticationResult authenticationResult = future.get();
 
             if (logger.isLoggable(Level.FINEST)) {
-                logger.finest(logger.toString() + " Access token expires on the following date: "
-                        + authenticationResult.expiresOnDate());
+                logger.finest(logger.toString() + ACCESS_TOKEN_EXPIRE + authenticationResult.expiresOnDate());
             }
 
             return new SqlAuthenticationToken(authenticationResult.accessToken(), authenticationResult.expiresOnDate());
@@ -138,8 +137,7 @@ class SQLServerMSAL4JUtils {
             final IAuthenticationResult authenticationResult = future.get();
 
             if (logger.isLoggable(Level.FINEST)) {
-                logger.finest(logger.toString() + " Access token expires on the following date: "
-                        + authenticationResult.expiresOnDate());
+                logger.finest(logger.toString() + ACCESS_TOKEN_EXPIRE + authenticationResult.expiresOnDate());
             }
 
             return new SqlAuthenticationToken(authenticationResult.accessToken(), authenticationResult.expiresOnDate());
@@ -204,8 +202,7 @@ class SQLServerMSAL4JUtils {
             }
 
             if (logger.isLoggable(Level.FINEST)) {
-                logger.finest(logger.toString() + " Access token expires on the following date: "
-                        + authenticationResult.expiresOnDate());
+                logger.finest(logger.toString() + ACCESS_TOKEN_EXPIRE + authenticationResult.expiresOnDate());
             }
 
             return new SqlAuthenticationToken(authenticationResult.accessToken(), authenticationResult.expiresOnDate());
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNoneEnclaveProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNoneEnclaveProvider.java
index 4bdabb93..cb20073b 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNoneEnclaveProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerNoneEnclaveProvider.java
@@ -33,7 +33,9 @@ public class SQLServerNoneEnclaveProvider implements ISQLServerEnclaveProvider {
     /**
      * default constructor
      */
-    public SQLServerNoneEnclaveProvider() {}
+    public SQLServerNoneEnclaveProvider() {
+        // default constructor
+    }
 
     @Override
     public void getAttestationParameters(String url) throws SQLServerException {
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
index 29afa5a5..ad666d7d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
@@ -57,6 +57,9 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     private static final int BATCH_STATEMENT_DELIMITER_TDS_71 = 0x80;
     private static final int BATCH_STATEMENT_DELIMITER_TDS_72 = 0xFF;
 
+    private static final String EXECUTE_BATCH_STRING = "executeBatch";
+    private static final String ACTIVITY_ID = " ActivityId: ";
+
     /** batch statement delimiter */
     final int nBatchStatementDelimiter = BATCH_STATEMENT_DELIMITER_TDS_72;
 
@@ -453,7 +456,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     public java.sql.ResultSet executeQuery() throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeQuery");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new PrepStmtExecCmd(this, EXECUTE_QUERY));
@@ -478,7 +481,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     public int executeUpdate() throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeUpdate");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         checkClosed();
@@ -500,7 +503,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
 
         loggerExternal.entering(getClassNameLogging(), "executeLargeUpdate");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new PrepStmtExecCmd(this, EXECUTE_UPDATE));
@@ -512,7 +515,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     public boolean execute() throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "execute");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new PrepStmtExecCmd(this, EXECUTE));
@@ -528,6 +531,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
          * Always update serialVersionUID when prompted.
          */
         private static final long serialVersionUID = 4098801171124750861L;
+
         private final SQLServerPreparedStatement stmt;
 
         PrepStmtExecCmd(SQLServerPreparedStatement stmt, int executeMethod) {
@@ -563,7 +567,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
         setMaxRowsAndMaxFieldSize();
 
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         boolean hasExistingTypeDefinitions = preparedTypeDefinitions != null;
@@ -986,7 +990,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                         }
                         SQLServerEncryptionType encType = SQLServerEncryptionType.of((byte) secondRs
                                 .getInt(DescribeParameterEncryptionResultSet2.COLUMNENCRYPTIONTYPE.value()));
-                        if (SQLServerEncryptionType.PlainText != encType) {
+                        if (SQLServerEncryptionType.PLAINTEXT != encType) {
                             params[paramIndex].cryptoMeta = new CryptoMetadata(cekEntry, (short) cekOrdinal,
                                     (byte) secondRs.getInt(
                                             DescribeParameterEncryptionResultSet2.COLUMNENCRYPTIONALGORITHM.value()),
@@ -2035,9 +2039,9 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
 
     @Override
     public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException {
-        loggerExternal.entering(getClassNameLogging(), "executeBatch");
+        loggerExternal.entering(getClassNameLogging(), EXECUTE_BATCH_STRING);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         discardLastExecutionResults();
@@ -2051,7 +2055,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                 if (this.useBulkCopyForBatchInsert && isInsert(localUserSQL)) {
                     if (null == batchParamValues) {
                         updateCounts = new int[0];
-                        loggerExternal.exiting(getClassNameLogging(), "executeBatch", updateCounts);
+                        loggerExternal.exiting(getClassNameLogging(), EXECUTE_BATCH_STRING, updateCounts);
                         return updateCounts;
                     }
 
@@ -2069,7 +2073,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                         for (Parameter paramValue : paramValues) {
                             if (paramValue.isOutput()) {
                                 throw new BatchUpdateException(
-                                        SQLServerException.getErrString("R_outParamsNotPermittedinBatch"), null, 0, null);
+                                        SQLServerException.getErrString("R_outParamsNotPermittedinBatch"), null, 0,
+                                        null);
                             }
                         }
                     }
@@ -2098,8 +2103,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                             }
                         }
 
-                        SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(batchParamValues,
-                                columnList, valueList, null);
+                        SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(
+                                batchParamValues, columnList, valueList, null);
 
                         for (int i = 1; i <= rs.getColumnCount(); i++) {
                             Column c = rs.getColumn(i);
@@ -2112,7 +2117,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                             } else {
                                 jdbctype = ti.getSSType().getJDBCType().getIntValue();
                             }
-                            batchRecord.addColumnMetadata(i, c.getColumnName(), jdbctype, ti.getPrecision(), ti.getScale());
+                            batchRecord.addColumnMetadata(i, c.getColumnName(), jdbctype, ti.getPrecision(),
+                                    ti.getScale());
                         }
 
                         SQLServerBulkCopy bcOperation = new SQLServerBulkCopy(connection);
@@ -2129,7 +2135,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                             updateCounts[i] = 1;
                         }
 
-                        loggerExternal.exiting(getClassNameLogging(), "executeBatch", updateCounts);
+                        loggerExternal.exiting(getClassNameLogging(), EXECUTE_BATCH_STRING, updateCounts);
                         return updateCounts;
                     }
                 }
@@ -2183,7 +2189,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                 }
             }
 
-            loggerExternal.exiting(getClassNameLogging(), "executeBatch", updateCounts);
+            loggerExternal.exiting(getClassNameLogging(), EXECUTE_BATCH_STRING, updateCounts);
             return updateCounts;
         } finally {
             batchParamValues = null;
@@ -2194,7 +2200,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     public long[] executeLargeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeLargeBatch");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         discardLastExecutionResults();
@@ -2226,7 +2232,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                         for (Parameter paramValue : paramValues) {
                             if (paramValue.isOutput()) {
                                 throw new BatchUpdateException(
-                                        SQLServerException.getErrString("R_outParamsNotPermittedinBatch"), null, 0, null);
+                                        SQLServerException.getErrString("R_outParamsNotPermittedinBatch"), null, 0,
+                                        null);
                             }
                         }
                     }
@@ -2255,8 +2262,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                             }
                         }
 
-                        SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(batchParamValues,
-                                columnList, valueList, null);
+                        SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(
+                                batchParamValues, columnList, valueList, null);
 
                         for (int i = 1; i <= rs.getColumnCount(); i++) {
                             Column c = rs.getColumn(i);
@@ -2269,7 +2276,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
                             } else {
                                 jdbctype = ti.getSSType().getJDBCType().getIntValue();
                             }
-                            batchRecord.addColumnMetadata(i, c.getColumnName(), jdbctype, ti.getPrecision(), ti.getScale());
+                            batchRecord.addColumnMetadata(i, c.getColumnName(), jdbctype, ti.getPrecision(),
+                                    ti.getScale());
                         }
 
                         SQLServerBulkCopy bcOperation = new SQLServerBulkCopy(connection);
@@ -2409,7 +2417,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
     }
 
     private String parseUserSQLForTableNameDW(boolean hasInsertBeenFound, boolean hasIntoBeenFound,
-            boolean hasTableBeenFound, boolean isExpectingTableName) {
+            boolean hasTableBeenFound, boolean isExpectingTableName) throws SQLServerException {
         // As far as finding the table name goes, There are two cases:
         // Insert into <tableName> and Insert <tableName>
         // And there could be in-line comments (with /* and */) in between.
@@ -2461,7 +2469,9 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
 
             // ] has not been found, this is wrong.
             if (tempint < 0) {
-                throw new IllegalArgumentException("Invalid SQL Query.");
+                MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidSqlQuery"));
+                Object[] msgArgs = {localUserSQL};
+                SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
             }
 
             // keep checking if it's escaped
@@ -2482,7 +2492,9 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
 
             // \" has not been found, this is wrong.
             if (tempint < 0) {
-                throw new IllegalArgumentException("Invalid SQL Query.");
+                MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidSqlQuery"));
+                Object[] msgArgs = {localUserSQL};
+                SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
             }
 
             // keep checking if it's escaped
@@ -2513,10 +2525,13 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
         }
 
         // It shouldn't come here. If we did, something is wrong.
-        throw new IllegalArgumentException("Invalid SQL Query.");
+        MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidSqlQuery"));
+        Object[] msgArgs = {localUserSQL};
+        SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
+        return "";
     }
 
-    private ArrayList<String> parseUserSQLForColumnListDW() {
+    private ArrayList<String> parseUserSQLForColumnListDW() throws SQLServerException {
         // ignore all comments
         while (checkAndRemoveCommentsAndSpace(false)) {}
 
@@ -2529,7 +2544,8 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
         return null;
     }
 
-    private ArrayList<String> parseUserSQLForColumnListDWHelper(ArrayList<String> listOfColumns) {
+    private ArrayList<String> parseUserSQLForColumnListDWHelper(
+            ArrayList<String> listOfColumns) throws SQLServerException {
         // ignore all comments
         while (checkAndRemoveCommentsAndSpace(false)) {}
 
@@ -2556,7 +2572,9 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
 
                 // ] has not been found, this is wrong.
                 if (tempint < 0) {
-                    throw new IllegalArgumentException("Invalid SQL Query.");
+                    MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_InvalidSqlQuery"));
+                    Object[] msgArgs = {localUserSQL};
+                    SQLServerException.makeFromDriverError(connection, this, form.format(msgArgs), null, false);
                 }
 
                 // keep checking if it's escaped
@@ -2801,7 +2819,7 @@ public class SQLServerPreparedStatement extends SQLServerStatement implements IS
         connection.setMaxRows(0);
 
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         // Create the parameter array that we'll use for all the items in this batch.
         Parameter[] batchParam = new Parameter[inOutParam.length];
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java
index 420905d8..96bd1847 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResource.java
@@ -516,7 +516,8 @@ public final class SQLServerResource extends ListResourceBundle {
         {"R_SecureStringInitFailed", "Failed to initialize SecureStringUtil to store secure strings"},
         {"R_ALPNFailed", "Failed to negotiate Application-Layer Protocol {0}. Server returned: {1}."},
         {"R_serverError", "An error occurred during the current command (Done status {0}). {1}"},
-        {"R_ManagedIdentityTokenAcquisitionFail", "Failed to acquire managed identity token. Request for the token succeeded, but no token was returned. The token is null."}
+        {"R_ManagedIdentityTokenAcquisitionFail", "Failed to acquire managed identity token. Request for the token succeeded, but no token was returned. The token is null."},
+        {"R_InvalidSqlQuery", "Invalid SQL Query: {0}"}
     };
 }
 // @formatter:on
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
index fabe2308..c50143ea 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java
@@ -58,6 +58,8 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     /** Generate the statement's logging ID */
     private static final AtomicInteger lastResultSetID = new AtomicInteger(0);
 
+    private static final String ACTIVITY_ID = " ActivityId: ";
+
     /** trace ID */
     private final String traceID;
 
@@ -652,7 +654,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void close() throws SQLServerException {
         loggerExternal.entering(getClassNameLogging(), "close");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         closeInternal();
         loggerExternal.exiting(getClassNameLogging(), "close");
@@ -1006,7 +1008,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public boolean next() throws SQLServerException {
         loggerExternal.entering(getClassNameLogging(), "next");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         if (logger.isLoggable(java.util.logging.Level.FINER))
             logger.finer(toString() + logCursorState());
@@ -1332,7 +1334,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void beforeFirst() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "beforeFirst");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         if (logger.isLoggable(java.util.logging.Level.FINER))
             logger.finer(toString() + logCursorState());
@@ -1363,7 +1365,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void afterLast() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "afterLast");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         if (logger.isLoggable(java.util.logging.Level.FINER))
@@ -1587,7 +1589,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public boolean absolute(int row) throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "absolute");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         if (logger.isLoggable(java.util.logging.Level.FINER))
             logger.finer(toString() + " row:" + row + logCursorState());
@@ -4682,7 +4684,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void insertRow() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "insertRow");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         final class InsertRowRPC extends TDSCommand {
@@ -4790,7 +4792,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void updateRow() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "updateRow");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         final class UpdateRowRPC extends TDSCommand {
             /**
@@ -4876,7 +4878,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void deleteRow() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "deleteRow");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         final class DeleteRowRPC extends TDSCommand {
             /**
@@ -4941,7 +4943,7 @@ public class SQLServerResultSet implements ISQLServerResultSet, java.io.Serializ
     public void refreshRow() throws SQLException {
         loggerExternal.entering(getClassNameLogging(), "refreshRow");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         if (logger.isLoggable(java.util.logging.Level.FINER))
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java
index 1fde31b0..1ac2b9ac 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSecurityUtility.java
@@ -199,7 +199,7 @@ class SQLServerSecurityUtility {
             throw new SQLServerException(null, SQLServerException.getErrString("R_CustomCipherAlgorithmNotSupportedAE"),
                     null, 0, false);
         }
-        return SQLServerAeadAes256CbcHmac256Algorithm.algorithmName;
+        return SQLServerAeadAes256CbcHmac256Algorithm.AEAD_AES_256_CBC_HMAC_SHA256;
     }
 
     /**
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
index 7fd08711..85a5986b 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
@@ -61,6 +61,8 @@ public class SQLServerStatement implements ISQLServerStatement {
     final static char LEFT_CURLY_BRACKET = 123;
     final static char RIGHT_CURLY_BRACKET = 125;
 
+    private static final String ACTIVITY_ID = " ActivityId: ";
+
     /** response buffer adaptive flag */
     private boolean isResponseBufferingAdaptive = false;
 
@@ -730,7 +732,7 @@ public class SQLServerStatement implements ISQLServerStatement {
     public java.sql.ResultSet executeQuery(String sql) throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeQuery", sql);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new StmtExecCmd(this, sql, EXECUTE_QUERY, NO_GENERATED_KEYS));
@@ -748,7 +750,7 @@ public class SQLServerStatement implements ISQLServerStatement {
     public int executeUpdate(String sql) throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeUpdate", sql);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new StmtExecCmd(this, sql, EXECUTE_UPDATE, NO_GENERATED_KEYS));
@@ -768,7 +770,7 @@ public class SQLServerStatement implements ISQLServerStatement {
 
         loggerExternal.entering(getClassNameLogging(), "executeLargeUpdate", sql);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new StmtExecCmd(this, sql, EXECUTE_UPDATE, NO_GENERATED_KEYS));
@@ -781,7 +783,7 @@ public class SQLServerStatement implements ISQLServerStatement {
     public boolean execute(String sql) throws SQLServerException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "execute", sql);
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         executeStatement(new StmtExecCmd(this, sql, EXECUTE, NO_GENERATED_KEYS));
@@ -884,7 +886,7 @@ public class SQLServerStatement implements ISQLServerStatement {
         setMaxRowsAndMaxFieldSize();
 
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         if (isCursorable(executeMethod) && isSelect(sql)) {
             if (stmtlogger.isLoggable(java.util.logging.Level.FINE))
@@ -974,7 +976,7 @@ public class SQLServerStatement implements ISQLServerStatement {
         }
 
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
 
         // Batch execution is always non-cursored
@@ -1836,7 +1838,7 @@ public class SQLServerStatement implements ISQLServerStatement {
     public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQLTimeoutException {
         loggerExternal.entering(getClassNameLogging(), "executeBatch");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         discardLastExecutionResults();
@@ -1913,7 +1915,7 @@ public class SQLServerStatement implements ISQLServerStatement {
 
         loggerExternal.entering(getClassNameLogging(), "executeLargeBatch");
         if (loggerExternal.isLoggable(Level.FINER) && Util.isActivityTraceOn()) {
-            loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+            loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
         }
         checkClosed();
         discardLastExecutionResults();
@@ -2100,7 +2102,7 @@ public class SQLServerStatement implements ISQLServerStatement {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
             loggerExternal.entering(getClassNameLogging(), "execute", new Object[] {sql, autoGeneratedKeys});
             if (Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
         }
         checkClosed();
@@ -2150,7 +2152,7 @@ public class SQLServerStatement implements ISQLServerStatement {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
             loggerExternal.entering(getClassNameLogging(), "executeUpdate", new Object[] {sql, autoGeneratedKeys});
             if (Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
         }
         checkClosed();
@@ -2178,7 +2180,7 @@ public class SQLServerStatement implements ISQLServerStatement {
         if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
             loggerExternal.entering(getClassNameLogging(), "executeLargeUpdate", new Object[] {sql, autoGeneratedKeys});
             if (Util.isActivityTraceOn()) {
-                loggerExternal.finer(toString() + " ActivityId: " + ActivityCorrelator.getNext().toString());
+                loggerExternal.finer(toString() + ACTIVITY_ID + ActivityCorrelator.getNext().toString());
             }
         }
         checkClosed();
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SecureStringUtil.java b/src/main/java/com/microsoft/sqlserver/jdbc/SecureStringUtil.java
index 172b013b..a90f7e8e 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SecureStringUtil.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SecureStringUtil.java
@@ -43,9 +43,11 @@ final class SecureStringUtil {
     private Cipher decryptCipher;
 
     /* singleton instance */
-    private static SecureStringUtil instance;
+    private static volatile SecureStringUtil instance;
 
-    private static final Lock LOCK = new ReentrantLock();
+    private static final Lock INSTANCE_LOCK = new ReentrantLock();
+    private static final Lock ENCRYPT_LOCK = new ReentrantLock();
+    private static final Lock DECRYPT_LOCK = new ReentrantLock();
 
     /**
      * Get reference to SecureStringUtil instance
@@ -57,13 +59,13 @@ final class SecureStringUtil {
      */
     static SecureStringUtil getInstance() throws SQLServerException {
         if (instance == null) {
-            LOCK.lock();
+            INSTANCE_LOCK.lock();
             try {
                 if (instance == null) {
                     instance = new SecureStringUtil();
                 }
             } finally {
-                LOCK.unlock();
+                INSTANCE_LOCK.unlock();
             }
         }
         return instance;
@@ -101,18 +103,19 @@ final class SecureStringUtil {
      * @return encrypted string
      * 
      * @throws SQLServerException
-     *         if error
+     *         Throws an exception if the method fails to encrypt the character array
      */
     byte[] getEncryptedBytes(char[] chars) throws SQLServerException {
-        if (chars == null)
-            return null;
-
-        byte[] iv = new byte[IV_LENGTH];
-        SecureRandom random = new SecureRandom();
-        random.nextBytes(iv);
-        GCMParameterSpec ivParamSpec = new GCMParameterSpec(TAG_LENGTH * 8, iv);
-
+        ENCRYPT_LOCK.lock();
         try {
+            if (chars == null) {
+                return null;
+            }
+
+            byte[] iv = new byte[IV_LENGTH];
+            SecureRandom random = new SecureRandom();
+            random.nextBytes(iv);
+            GCMParameterSpec ivParamSpec = new GCMParameterSpec(TAG_LENGTH * 8, iv);
             encryptCipher.init(Cipher.ENCRYPT_MODE, secretKey, ivParamSpec);
 
             byte[] cipherText = encryptCipher.doFinal(Util.charsToBytes(chars));
@@ -124,6 +127,8 @@ final class SecureStringUtil {
             MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_EncryptionFailed"));
             Object[] msgArgs = {e.getMessage()};
             throw new SQLServerException(this, form.format(msgArgs), null, 0, false);
+        } finally {
+            ENCRYPT_LOCK.unlock();
         }
     }
 
@@ -131,22 +136,25 @@ final class SecureStringUtil {
      * Get decrypted value of an encrypted string
      * 
      * @param bytes
+     *        The byte array to decrypt into a character array
      * 
      * @return decrypted string
      * 
      * @throws SQLServerException
+     *         Throws an exception if the method fails to decrypt the byte array
      */
     char[] getDecryptedChars(byte[] bytes) throws SQLServerException {
-        if (bytes == null)
-            return null;
-
-        byte[] iv = new byte[IV_LENGTH];
-        System.arraycopy(bytes, 0, iv, 0, IV_LENGTH);
-
-        GCMParameterSpec ivParamSpec = new GCMParameterSpec(TAG_LENGTH * 8, iv);
-
+        DECRYPT_LOCK.lock();
         byte[] plainText = null;
         try {
+            if (bytes == null) {
+                return null;
+            }
+
+            byte[] iv = new byte[IV_LENGTH];
+            System.arraycopy(bytes, 0, iv, 0, IV_LENGTH);
+
+            GCMParameterSpec ivParamSpec = new GCMParameterSpec(TAG_LENGTH * 8, iv);
             decryptCipher.init(Cipher.DECRYPT_MODE, secretKey, ivParamSpec);
 
             plainText = decryptCipher.doFinal(bytes, IV_LENGTH, bytes.length - IV_LENGTH);
@@ -159,6 +167,7 @@ final class SecureStringUtil {
             if (plainText != null) {
                 Arrays.fill(plainText, (byte) 0);
             }
+            DECRYPT_LOCK.unlock();
         }
     }
 }


Test patch:
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java
index 24bc18dd..1e8d0d04 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java
@@ -61,7 +61,7 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL
             return AuthenticationJNI.DecryptColumnEncryptionKey(masterKeyPath, encryptionAlgorithm,
                     encryptedColumnEncryptionKey);
         } catch (DLLException e) {
-            DLLException.buildException(e.getErrCode(), e.GetParam1(), e.GetParam2(), e.GetParam3());
+            DLLException.buildException(e.getErrCode(), e.getParam1(), e.getParam2(), e.getParam3());
             return null;
         }
     }
@@ -88,7 +88,7 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL
         try {
             return AuthenticationJNI.VerifyColumnMasterKeyMetadata(masterKeyPath, allowEnclaveComputations, signature);
         } catch (DLLException e) {
-            DLLException.buildException(e.getErrCode(), e.GetParam1(), e.GetParam2(), e.GetParam3());
+            DLLException.buildException(e.getErrCode(), e.getParam1(), e.getParam2(), e.getParam3());
             return false;
         }
     }
diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java
index 1324ff8a..8ea0a86a 100644
--- a/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java
+++ b/src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthTest.java
@@ -251,7 +251,7 @@ public class FedauthTest extends FedauthCommon {
      * encryption, in addition to application name in order to use different authorities.
      *
      * @throws Exception
-     *          if an exception occurs
+     *         if an exception occurs
      */
     @Test
     public void testAADPasswordApplicationName() throws Exception {
@@ -263,8 +263,7 @@ public class FedauthTest extends FedauthCommon {
         SQLServerDataSource ds = new SQLServerDataSource();
         ds.setURL(url);
 
-        try (Connection con = ds.getConnection()) {
-        } catch (Exception e) {
+        try (Connection con = ds.getConnection()) {} catch (Exception e) {
             fail(e.getMessage());
         }
     }
@@ -275,6 +274,7 @@ public class FedauthTest extends FedauthCommon {
      * 
      * @deprecated
      */
+    @Deprecated
     @Test
     public void testAADServicePrincipalAuthDeprecated() {
         String url = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";authentication="