diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java index 4a38df69e..91a473b73 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerColumnEncryptionCertificateStoreProvider.java @@ -45,7 +45,12 @@ public final class SQLServerColumnEncryptionCertificateStoreProvider extends SQL static final String myCertificateStore = "My"; static { - isWindows = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows"); + if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).startsWith("windows")) { + isWindows = true; + } + else { + isWindows = false; + } } private Path keyStoreDirectoryPath = null; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java index 34bafaea7..516a4d590 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDatabaseMetaData.java @@ -1968,7 +1968,10 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) { case ResultSet.TYPE_SCROLL_INSENSITIVE: // case SQLServerResultSet.TYPE_SS_SCROLL_STATIC: sensitive synonym case SQLServerResultSet.TYPE_SS_DIRECT_FORWARD_ONLY: - return ResultSet.CONCUR_READ_ONLY == concurrency; + if (ResultSet.CONCUR_READ_ONLY == concurrency) + return true; + else + return false; } // per spec if we do not know we do not support. return false; @@ -1977,48 +1980,60 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) { /* L0 */ public boolean ownUpdatesAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type || SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean ownDeletesAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type || SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean ownInsertsAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type || SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean othersUpdatesAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type || SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean othersDeletesAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type || SQLServerResultSet.TYPE_SCROLL_SENSITIVE == type || SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean othersInsertsAreVisible(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type - || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type; + if (type == SQLServerResultSet.TYPE_SS_SCROLL_DYNAMIC || SQLServerResultSet.TYPE_FORWARD_ONLY == type + || SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY == type) + return true; + return false; } /* L0 */ public boolean updatesAreDetected(int type) throws SQLServerException { @@ -2030,7 +2045,10 @@ else if (name.equals(SQLServerDriverIntProperty.PORT_NUMBER.toString())) { /* L0 */ public boolean deletesAreDetected(int type) throws SQLServerException { checkClosed(); checkResultType(type); - return SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type; + if (SQLServerResultSet.TYPE_SS_SCROLL_KEYSET == type) + return true; + else + return false; } // Check the result types to make sure the user does not pass a bad value. diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java index 601e06274..1d11e61af 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java @@ -581,7 +581,12 @@ private void checkClosed() throws SQLServerException { rsProcedureMeta = s.executeQueryInternal("exec sp_sproc_columns " + sProc + ", @ODBCVer=3"); // if rsProcedureMeta has next row, it means the stored procedure is found - procedureIsFound = rsProcedureMeta.next(); + if (rsProcedureMeta.next()) { + procedureIsFound = true; + } + else { + procedureIsFound = false; + } rsProcedureMeta.beforeFirst(); // Sixth is DATA_TYPE diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java index 8c58a8c94..e937b27c3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSet.java @@ -6280,7 +6280,8 @@ boolean onRow(TDSReader tdsReader) throws SQLServerException { // Consume the ROW token, leaving tdsReader at the start of // this row's column values. - assert TDS.TDS_ROW == tdsReader.readUnsignedByte(); + if (TDS.TDS_ROW != tdsReader.readUnsignedByte()) + assert false; fetchBufferCurrentRowType = RowType.ROW; return false; } @@ -6290,7 +6291,8 @@ boolean onNBCRow(TDSReader tdsReader) throws SQLServerException { // Consume the NBCROW token, leaving tdsReader at the start of // nullbitmap. - assert TDS.TDS_NBCROW == tdsReader.readUnsignedByte(); + if (TDS.TDS_NBCROW != tdsReader.readUnsignedByte()) + assert false; fetchBufferCurrentRowType = RowType.NBCROW; return false; diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java index 366307b34..e0d7eaeb5 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColInfo.java @@ -21,7 +21,8 @@ final class StreamColInfo extends StreamPacket { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_COLINFO == tdsReader.readUnsignedByte() : "Not a COLINFO token"; + if (TDS.TDS_COLINFO != tdsReader.readUnsignedByte()) + assert false : "Not a COLINFO token"; this.tdsReader = tdsReader; int tokenLength = tdsReader.readUnsignedShort(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java index 0553cb47b..3128fb318 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java @@ -163,7 +163,8 @@ CryptoMetadata readCryptoMetadata(TDSReader tdsReader) throws SQLServerException * @throws SQLServerException */ void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_COLMETADATA == tdsReader.readUnsignedByte(); + if (TDS.TDS_COLMETADATA != tdsReader.readUnsignedByte()) + assert false; int nTotColumns = tdsReader.readUnsignedShort(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java index 62c0ebdd3..c7d2418db 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamError.java @@ -47,7 +47,8 @@ final int getErrorSeverity() { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_ERR == tdsReader.readUnsignedByte(); + if (TDS.TDS_ERR != tdsReader.readUnsignedByte()) + assert false; setContentsFromTDS(tdsReader); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java index fe55ae1f9..ef32b463f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamInfo.java @@ -16,7 +16,8 @@ final class StreamInfo extends StreamPacket { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_MSG == tdsReader.readUnsignedByte(); + if (TDS.TDS_MSG != tdsReader.readUnsignedByte()) + assert false; msg.setContentsFromTDS(tdsReader); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java index 608b452d2..1abe2a133 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamLoginAck.java @@ -22,7 +22,8 @@ final class StreamLoginAck extends StreamPacket { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_LOGIN_ACK == tdsReader.readUnsignedByte(); + if (TDS.TDS_LOGIN_ACK != tdsReader.readUnsignedByte()) + assert false; tdsReader.readUnsignedShort(); // length of this token stream tdsReader.readUnsignedByte(); // SQL version accepted by the server tdsVersion = tdsReader.readIntBigEndian(); // TDS version accepted by the server diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java index 54ab19249..51b44cde0 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetStatus.java @@ -25,7 +25,8 @@ final int getStatus() { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_RET_STAT == tdsReader.readUnsignedByte(); + if (TDS.TDS_RET_STAT != tdsReader.readUnsignedByte()) + assert false; status = tdsReader.readInt(); } } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java index 35d3b17fd..c2947dd56 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamRetValue.java @@ -33,7 +33,8 @@ final int getOrdinalOrLength() { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_RETURN_VALUE == tdsReader.readUnsignedByte(); + if (TDS.TDS_RETURN_VALUE != tdsReader.readUnsignedByte()) + assert false; ordinalOrLength = tdsReader.readUnsignedShort(); paramName = tdsReader.readUnicodeString(tdsReader.readUnsignedByte()); status = tdsReader.readUnsignedByte(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java index fca3e0cd0..1a9b4d346 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamSSPI.java @@ -21,7 +21,8 @@ final class StreamSSPI extends StreamPacket { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_SSPI == tdsReader.readUnsignedByte(); + if (TDS.TDS_SSPI != tdsReader.readUnsignedByte()) + assert false; int blobLength = tdsReader.readUnsignedShort(); sspiBlob = new byte[blobLength]; tdsReader.readBytes(sspiBlob, 0, blobLength); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java index d728785b6..31acff46f 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamTabName.java @@ -22,7 +22,8 @@ final class StreamTabName extends StreamPacket { } void setFromTDS(TDSReader tdsReader) throws SQLServerException { - assert TDS.TDS_TABNAME == tdsReader.readUnsignedByte() : "Not a TABNAME token"; + if (TDS.TDS_TABNAME != tdsReader.readUnsignedByte()) + assert false : "Not a TABNAME token"; this.tdsReader = tdsReader; int tokenLength = tdsReader.readUnsignedShort(); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java index eb585e540..db10ebce1 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/Util.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/Util.java @@ -790,7 +790,10 @@ static final String readGUID(byte[] inputGUID) throws SQLServerException { static boolean IsActivityTraceOn() { LogManager lm = LogManager.getLogManager(); String activityTrace = lm.getProperty(ActivityIdTraceProperty); - return "on".equalsIgnoreCase(activityTrace); + if ("on".equalsIgnoreCase(activityTrace)) + return true; + else + return false; } /**