From ded790c6cd52a9d63aebb261257b44a2d2caf63f Mon Sep 17 00:00:00 2001 From: rene-ye Date: Mon, 5 Feb 2018 13:45:14 -0800 Subject: [PATCH 1/2] Added information to error message To debug a random mismatch error which can't be reproduced locally. --- .../sqlserver/testframework/util/ComparisonUtil.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/testframework/util/ComparisonUtil.java b/src/test/java/com/microsoft/sqlserver/testframework/util/ComparisonUtil.java index c942f8c9a..b297a3924 100644 --- a/src/test/java/com/microsoft/sqlserver/testframework/util/ComparisonUtil.java +++ b/src/test/java/com/microsoft/sqlserver/testframework/util/ComparisonUtil.java @@ -92,16 +92,16 @@ public static void compareExpectedAndActual(int dataType, else switch (dataType) { case java.sql.Types.BIGINT: - assertTrue((((Long) expectedValue).longValue() == ((Long) actualValue).longValue()), "Unexpected bigint value"); + assertTrue((((Long) expectedValue).longValue() == ((Long) actualValue).longValue()), "Unexpected bigint value. Expected:" + ((Long) expectedValue).longValue() + " Actual:" + ((Long) actualValue).longValue()); break; case java.sql.Types.INTEGER: - assertTrue((((Integer) expectedValue).intValue() == ((Integer) actualValue).intValue()), "Unexpected int value"); + assertTrue((((Integer) expectedValue).intValue() == ((Integer) actualValue).intValue()), "Unexpected int value. Expected:" + ((Integer) expectedValue).intValue() + " Actual:" + ((Integer) actualValue).intValue()); break; case java.sql.Types.SMALLINT: case java.sql.Types.TINYINT: - assertTrue((((Short) expectedValue).shortValue() == ((Short) actualValue).shortValue()), "Unexpected smallint/tinyint value"); + assertTrue((((Short) expectedValue).shortValue() == ((Short) actualValue).shortValue()), "Unexpected smallint/tinyint value. Expected:" + ((Short) expectedValue).shortValue() + " Actual:" + ((Short) actualValue).shortValue()); break; case java.sql.Types.BIT: @@ -115,11 +115,11 @@ public static void compareExpectedAndActual(int dataType, break; case java.sql.Types.DOUBLE: - assertTrue((((Double) expectedValue).doubleValue() == ((Double) actualValue).doubleValue()), "Unexpected float value"); + assertTrue((((Double) expectedValue).doubleValue() == ((Double) actualValue).doubleValue()), "Unexpected double value. Expected:" + ((Double) expectedValue).doubleValue() + " Actual:" + ((Double) actualValue).doubleValue()); break; case java.sql.Types.REAL: - assertTrue((((Float) expectedValue).floatValue() == ((Float) actualValue).floatValue()), "Unexpected real value"); + assertTrue((((Float) expectedValue).floatValue() == ((Float) actualValue).floatValue()), "Unexpected real/float value. Expected:" + ((Float) expectedValue).floatValue() + " Actual:" + ((Float) actualValue).floatValue()); break; case java.sql.Types.VARCHAR: From c2d0997b0aa0e36c03b130ce792e68db0bf89c6d Mon Sep 17 00:00:00 2001 From: rene-ye Date: Tue, 6 Feb 2018 11:58:21 -0800 Subject: [PATCH 2/2] unexpected error message don't attempt mismatch logic if there's no columns to look for. fall through to sql server and do a lookup on the first column. --- .../microsoft/sqlserver/jdbc/SQLServerCallableStatement.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java index 5ad8689c8..c30eab2fa 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerCallableStatement.java @@ -1450,6 +1450,8 @@ public NClob getNClob(String parameterName) throws SQLException { int l = 0; if (paramNames != null) l = paramNames.size(); + if (l == 0)//Server didn't return anything, user might not have access + return 1;//attempting to look up the first column will return no access exception // handle `@name` as well as `name`, since `@name` is what's returned // by DatabaseMetaData#getProcedureColumns