diff --git a/build.gradle b/build.gradle
index aa88d5d71..d3b7e8332 100644
--- a/build.gradle
+++ b/build.gradle
@@ -88,16 +88,16 @@ dependencies {
'com.microsoft.azure:azure-keyvault-webkey:1.2.0',
'com.microsoft.rest:client-runtime:1.6.5',
'com.microsoft.azure:adal4j:1.6.3'
- testCompile 'org.junit.platform:junit-platform-console:1.3.2',
- 'org.junit.platform:junit-platform-commons:1.3.2',
- 'org.junit.platform:junit-platform-engine:1.3.2',
- 'org.junit.platform:junit-platform-launcher:1.3.2',
- 'org.junit.platform:junit-platform-runner:1.3.2',
+ testCompile 'org.junit.platform:junit-platform-console:1.4.0',
+ 'org.junit.platform:junit-platform-commons:1.4.0',
+ 'org.junit.platform:junit-platform-engine:1.4.0',
+ 'org.junit.platform:junit-platform-launcher:1.4.0',
+ 'org.junit.platform:junit-platform-runner:1.4.0',
'org.junit.platform:junit-platform-surefire-provider:1.3.2',
- 'org.junit.jupiter:junit-jupiter-api:5.3.2',
- 'org.junit.jupiter:junit-jupiter-engine:5.3.2',
- 'com.zaxxer:HikariCP:3.2.0',
- 'org.apache.commons:commons-dbcp2:2.5.0',
- 'org.slf4j:slf4j-nop:1.7.25',
- 'org.eclipse.gemini.blueprint:gemini-blueprint-mock:2.0.0.RELEASE'
+ 'org.junit.jupiter:junit-jupiter-api:5.4.0',
+ 'org.junit.jupiter:junit-jupiter-engine:5.4.0',
+ 'com.zaxxer:HikariCP:3.3.1',
+ 'org.apache.commons:commons-dbcp2:2.6.0',
+ 'org.slf4j:slf4j-nop:1.7.26',
+ 'org.eclipse.gemini.blueprint:gemini-blueprint-mock:2.1.0.RELEASE'
}
diff --git a/pom.xml b/pom.xml
index 12c3c243a..3df39e7b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,35 +39,44 @@
UTF-8
- 1.3.2
- 5.3.2
+
+ 1.2.0
+ 1.6.3
+ 1.6.5
4.3.1
+
+ [1.3.2,1.4.0]
+ 5.4.0
+ 3.3.1
+ 2.6.0
+ 1.7.26
+ 2.1.0.RELEASE
com.microsoft.azure
azure-keyvault
- 1.2.0
+ ${azure.keyvault.version}
true
com.microsoft.azure
azure-keyvault-webkey
- 1.2.0
+ ${azure.keyvault.version}
true
com.microsoft.azure
adal4j
- 1.6.3
+ ${azure.adal4j.version}
true
com.microsoft.rest
client-runtime
- 1.6.5
+ ${rest.client.version}
true
@@ -137,25 +146,25 @@
com.zaxxer
HikariCP
- 3.2.0
+ ${hikaricp.version}
test
org.apache.commons
commons-dbcp2
- 2.5.0
+ ${dbcp2.version}
test
org.slf4j
slf4j-nop
- 1.7.25
+ ${slf4j.nop.version}
test
org.eclipse.gemini.blueprint
gemini-blueprint-mock
- 2.0.0.RELEASE
+ ${gemini.mock.version}
test
@@ -407,6 +416,7 @@
3.0.0
true
+ mssql.googlecode.*
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
index fab2ff503..794253372 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java
@@ -47,7 +47,6 @@
import java.util.logging.Level;
import javax.sql.RowSet;
-import javax.sql.XAConnection;
import microsoft.sql.DateTimeOffset;
@@ -888,6 +887,7 @@ private void writeTypeInfo(TDSWriter tdsWriter, int srcJdbcType, int srcScale, i
}
break;
+ case java.sql.Types.FLOAT:
case java.sql.Types.DOUBLE: // (FLT8TYPE) 0x3E
if (!srcNullable) {
tdsWriter.writeByte(TDSType.FLOAT8.byteValue());
@@ -1244,6 +1244,7 @@ private String getDestTypeFromSrcType(int srcColIndx, int destColIndx,
case java.sql.Types.TINYINT:
return "tinyint";
+ case java.sql.Types.FLOAT:
case java.sql.Types.DOUBLE:
return "float";
@@ -1929,6 +1930,7 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,
case java.sql.Types.BIGINT:
case java.sql.Types.REAL:
case java.sql.Types.DOUBLE:
+ case java.sql.Types.FLOAT:
case java.sql.Types.DECIMAL:
case java.sql.Types.NUMERIC:
case java.sql.Types.TIMESTAMP:
@@ -2051,6 +2053,17 @@ else if (null != sourceCryptoMeta) {
}
break;
+ case java.sql.Types.FLOAT:
+ if (null == colValue) {
+ writeNullToTdsWriter(tdsWriter, bulkJdbcType, isStreaming);
+ } else {
+ if (bulkNullable) {
+ tdsWriter.writeByte((byte) 0x08);
+ }
+ tdsWriter.writeDouble((float) colValue);
+ }
+ break;
+
case java.sql.Types.DOUBLE:
if (null == colValue) {
writeNullToTdsWriter(tdsWriter, bulkJdbcType, isStreaming);
@@ -2701,6 +2714,7 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
case java.sql.Types.TINYINT:
case java.sql.Types.DOUBLE:
case java.sql.Types.REAL:
+ case java.sql.Types.FLOAT:
return sourceResultSet.getObject(srcColOrdinal);
case microsoft.sql.Types.MONEY:
@@ -3334,12 +3348,11 @@ private byte[] normalizedValue(JDBCType destJdbcType, Object value, JDBCType src
return ((String) value).getBytes(UTF_16LE);
case REAL:
- case FLOAT:
-
Float floatValue = (value instanceof String) ? Float.parseFloat((String) value) : (Float) value;
return ByteBuffer.allocate((Float.SIZE / Byte.SIZE)).order(ByteOrder.LITTLE_ENDIAN)
.putFloat(floatValue).array();
-
+
+ case FLOAT:
case DOUBLE:
Double doubleValue = (value instanceof String) ? Double.parseDouble((String) value)
: (Double) value;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
index b779bed2e..633587a38 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
@@ -140,7 +140,12 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
private String originalHostNameInCertificate = null;
+ final int ENGINE_EDITION_FOR_SQL_AZURE = 5;
+ final int ENGINE_EDITION_FOR_SQL_AZURE_DW = 6;
+ final int ENGINE_EDITION_FOR_SQL_AZURE_MI = 8;
+ private Boolean isAzure = null;
private Boolean isAzureDW = null;
+ private Boolean isAzureMI = null;
private SharedTimer sharedTimer;
@@ -3164,16 +3169,10 @@ public void rollback() throws SQLServerException {
public void abort(Executor executor) throws SQLException {
loggerExternal.entering(getClassNameLogging(), "abort", executor);
- // nop if connection is closed
+ // no-op if connection is closed
if (isClosed())
return;
- if (null == executor) {
- MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidArgument"));
- Object[] msgArgs = {"executor"};
- SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, false);
- }
-
// check for callAbort permission
SecurityManager secMgr = System.getSecurityManager();
if (secMgr != null) {
@@ -3186,11 +3185,20 @@ public void abort(Executor executor) throws SQLException {
SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, true);
}
}
+ if (null == executor) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidArgument"));
+ Object[] msgArgs = {"executor"};
+ SQLServerException.makeFromDriverError(null, null, form.format(msgArgs), null, false);
+ } else {
- setState(State.Closed);
+ /*
+ * Always report the connection as closed for any further use, no matter what happens when we try to clean
+ * up the physical resources associated with the connection using executor.
+ */
+ setState(State.Closed);
- if (null != tdsChannel && null != executor)
- executor.execute(() -> tdsChannel.close());
+ executor.execute(() -> clearConnectionResources());
+ }
loggerExternal.exiting(getClassNameLogging(), "abort");
}
@@ -3199,19 +3207,27 @@ public void abort(Executor executor) throws SQLException {
public void close() throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "close");
- // Always report the connection as closed for any further use, no matter
- // what happens when we try to clean up the physical resources associated
- // with the connection.
+ /*
+ * Always report the connection as closed for any further use, no matter what happens when we try to clean up
+ * the physical resources associated with the connection.
+ */
setState(State.Closed);
+ clearConnectionResources();
+
+ loggerExternal.exiting(getClassNameLogging(), "close");
+ }
+
+ private void clearConnectionResources() {
if (sharedTimer != null) {
sharedTimer.removeRef();
sharedTimer = null;
}
- // Close the TDS channel. When the channel is closed, the server automatically
- // rolls back any pending transactions and closes associated resources like
- // prepared handles.
+ /*
+ * Close the TDS channel. When the channel is closed, the server automatically rolls back any pending
+ * transactions and closes associated resources like prepared handles.
+ */
if (null != tdsChannel) {
tdsChannel.close();
}
@@ -3227,8 +3243,6 @@ public void close() throws SQLServerException {
cleanupPreparedStatementDiscardActions();
ActivityCorrelator.cleanupActivityId();
-
- loggerExternal.exiting(getClassNameLogging(), "close");
}
// This function is used by the proxy for notifying the pool manager that this connection proxy is closed
@@ -6227,35 +6241,57 @@ public void onEviction(CityHash128Key key, PreparedStatementHandle handle) {
}
}
}
-
- boolean isAzureDW() throws SQLServerException, SQLException {
- if (null == isAzureDW) {
- try (Statement stmt = this.createStatement();
- ResultSet rs = stmt.executeQuery("SELECT CAST(SERVERPROPERTY('EngineEdition') as INT)")) {
- // SERVERPROPERTY('EngineEdition') can be used to determine whether the db server is SQL Azure.
- // It should return 6 for SQL Azure DW. This is more reliable than @@version or
- // serverproperty('edition').
- // Reference: http://msdn.microsoft.com/en-us/library/ee336261.aspx
- //
- // SERVERPROPERTY('EngineEdition') means
- // Database Engine edition of the instance of SQL Server installed on the server.
- // 1 = Personal or Desktop Engine (Not available for SQL Server.)
- // 2 = Standard (This is returned for Standard and Workgroup.)
- // 3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and Developer.)
- // 4 = Express (This is returned for Express, Express with Advanced Services, and Windows Embedded SQL.)
- // 5 = SQL Azure
- // 6 = SQL Azure DW
- // Base data type: int
- final int ENGINE_EDITION_FOR_SQL_AZURE_DW = 6;
+
+ /*
+ * SERVERPROPERTY('EngineEdition') can be used to determine whether the db server is SQL Azure.
+ * It should return 6 for SQL Azure DW. This is more reliable than @@version or
+ * serverproperty('edition').
+ * Reference: http://msdn.microsoft.com/en-us/library/ee336261.aspx
+ *
+ * SERVERPROPERTY('EngineEdition') means
+ * Database Engine edition of the instance of SQL Server installed on the server.
+ * 1 = Personal or Desktop Engine (Not available for SQL Server.)
+ * 2 = Standard (This is returned for Standard and Workgroup.)
+ * 3 = Enterprise (This is returned for Enterprise, Enterprise Evaluation, and Developer.)
+ * 4 = Express (This is returned for Express, Express with Advanced Services, and Windows Embedded SQL.)
+ * 5 = SQL Azure
+ * 6 = SQL Azure DW
+ * 8 = Managed Instance
+ * Base data type: int
+ */
+ boolean isAzure() {
+ if (null == isAzure) {
+ try (Statement stmt = this.createStatement(); ResultSet rs = stmt.executeQuery("SELECT CAST(SERVERPROPERTY('EngineEdition') as INT)")) {
rs.next();
- isAzureDW = rs.getInt(1) == ENGINE_EDITION_FOR_SQL_AZURE_DW;
+
+ int engineEdition = rs.getInt(1);
+ isAzure = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE || engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_DW || engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_MI);
+ isAzureDW = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_DW);
+ isAzureMI = (engineEdition == ENGINE_EDITION_FOR_SQL_AZURE_MI);
+
+ } catch (SQLException e) {
+ if (loggerExternal.isLoggable(java.util.logging.Level.FINER))
+ loggerExternal.log(Level.FINER, this + ": Error retrieving server type", e);
+ isAzure = false;
+ isAzureDW = false;
+ isAzureMI = false;
}
- return isAzureDW;
+ return isAzure;
} else {
- return isAzureDW;
+ return isAzure;
}
}
+ boolean isAzureDW() {
+ isAzure();
+ return isAzureDW;
+ }
+
+ boolean isAzureMI() {
+ isAzure();
+ return isAzureMI;
+ }
+
/**
* Adds statement to openStatements
*
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java
index 760f3f082..4f3edc2e9 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java
@@ -8,7 +8,6 @@
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
import java.text.MessageFormat;
import java.util.Enumeration;
import java.util.Locale;
@@ -126,6 +125,7 @@ private SSLProtocol(String name) {
this.name = name;
}
+ @Override
public String toString() {
return name;
}
@@ -207,6 +207,7 @@ private ApplicationIntent(String value) {
/**
* Returns the string value of enum.
*/
+ @Override
public String toString() {
return value;
}
@@ -250,6 +251,7 @@ public String getDefaultValue() {
return defaultValue;
}
+ @Override
public String toString() {
return name;
}
@@ -298,6 +300,7 @@ String getDefaultValue() {
return defaultValue;
}
+ @Override
public String toString() {
return name;
}
@@ -327,6 +330,7 @@ int getDefaultValue() {
return defaultValue;
}
+ @Override
public String toString() {
return name;
}
@@ -361,6 +365,7 @@ boolean getDefaultValue() {
return defaultValue;
}
+ @Override
public String toString() {
return name;
}
@@ -539,6 +544,7 @@ private static int nextInstanceID() {
return baseID.incrementAndGet();
}
+ @Override
final public String toString() {
return traceID;
}
@@ -720,6 +726,7 @@ static String getPropertyOnlyName(String name, Logger logger) {
return null;
}
+ @Override
public java.sql.Connection connect(String Url, Properties suppliedProperties) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "connect", "Arguments not traced.");
SQLServerConnection result = null;
@@ -759,6 +766,7 @@ private Properties parseAndMergeProperties(String Url, Properties suppliedProper
return connectProperties;
}
+ @Override
public boolean acceptsURL(String url) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "acceptsURL", "Arguments not traced.");
@@ -777,6 +785,7 @@ public boolean acceptsURL(String url) throws SQLServerException {
return result;
}
+ @Override
public DriverPropertyInfo[] getPropertyInfo(String Url, Properties Info) throws SQLServerException {
loggerExternal.entering(getClassNameLogging(), "getPropertyInfo", "Arguments not traced.");
@@ -798,22 +807,26 @@ static final DriverPropertyInfo[] getPropertyInfoFromProperties(Properties props
return properties;
}
+ @Override
public int getMajorVersion() {
loggerExternal.entering(getClassNameLogging(), "getMajorVersion");
loggerExternal.exiting(getClassNameLogging(), "getMajorVersion", SQLJdbcVersion.major);
return SQLJdbcVersion.major;
}
+ @Override
public int getMinorVersion() {
loggerExternal.entering(getClassNameLogging(), "getMinorVersion");
loggerExternal.exiting(getClassNameLogging(), "getMinorVersion", SQLJdbcVersion.minor);
return SQLJdbcVersion.minor;
}
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ @Override
+ public Logger getParentLogger() {
return parentLogger;
}
+ @Override
public boolean jdbcCompliant() {
loggerExternal.entering(getClassNameLogging(), "jdbcCompliant");
loggerExternal.exiting(getClassNameLogging(), "jdbcCompliant", Boolean.TRUE);
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java
index 41eb1b5c6..52603994d 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerLob.java
@@ -8,7 +8,7 @@
import java.sql.SQLException;
-abstract class SQLServerLob implements Serializable{
+abstract class SQLServerLob implements Serializable {
/**
* Always update serialVersionUID when prompted.
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java
index dfb43f756..aef7aac02 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerMetaData.java
@@ -61,8 +61,8 @@ public SQLServerMetaData(String columnName, int sqlType, int precision, int scal
}
/**
- * Constructs a SQLServerMetaData with the column name, SQL type, and length (for String data).
- * The length is used to differentiate large strings from strings with length less than 4000 characters.
+ * Constructs a SQLServerMetaData with the column name, SQL type, and length (for String data). The length is used
+ * to differentiate large strings from strings with length less than 4000 characters.
*
* @param columnName
* the name of the column
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java
index 4d95cda9a..1efbd8572 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerParameterMetaData.java
@@ -254,7 +254,7 @@ private void parseQueryMeta(ResultSet rsQueryMeta) throws SQLServerException {
SQLServerException.getErrString("R_metaDataErrorForParameter"));
Object[] msgArgs = {paramOrdinal};
SQLServerException.makeFromDriverError(con, stmtParent,
- form.format(msgArgs) + " " + e.toString(), null, false);
+ form.format(msgArgs) + " " + e.getMessage(), null, false);
}
}
} else
@@ -547,8 +547,8 @@ private void checkClosed() throws SQLServerException {
* the procedure name
* @throws SQLServerException
*/
+ @SuppressWarnings("serial")
SQLServerParameterMetaData(SQLServerPreparedStatement st, String sProcString) throws SQLServerException {
-
assert null != st;
stmtParent = st;
con = st.connection;
@@ -612,9 +612,8 @@ private void checkClosed() throws SQLServerException {
if (con.getServerMajorVersion() >= SQL_SERVER_2012_VERSION) {
// new implementation for SQL verser 2012 and above
- String preparedSQL = con.replaceParameterMarkers((stmtParent).userSQL,
- (stmtParent).userSQLParamPositions, (stmtParent).inOutParam,
- (stmtParent).bReturnValueSyntax);
+ String preparedSQL = con.replaceParameterMarkers(stmtParent.userSQL,
+ stmtParent.userSQLParamPositions, stmtParent.inOutParam, stmtParent.bReturnValueSyntax);
try (SQLServerCallableStatement cstmt = (SQLServerCallableStatement) con
.prepareCall("exec sp_describe_undeclared_parameters ?")) {
@@ -680,9 +679,9 @@ private void checkClosed() throws SQLServerException {
catch (SQLServerException e) {
throw e;
} catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
+ SQLServerException.makeFromDriverError(con, stmtParent, e.getMessage(), null, false);
} catch (StringIndexOutOfBoundsException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
+ SQLServerException.makeFromDriverError(con, stmtParent, e.getMessage(), null, false);
}
}
@@ -703,49 +702,58 @@ public T unwrap(Class iface) throws SQLException {
return t;
}
- private Map getParameterInfo(int param) throws SQLServerException {
- boolean paramFound = false;
- if ((stmtParent).bReturnValueSyntax && isTVP) {
- paramFound = procMetadata.size() >= param;
- if (paramFound) {
- return procMetadata.get(param - 1);
- }
+ private Map getParameterInfo(int param) {
+ if (stmtParent.bReturnValueSyntax && isTVP) {
+ return procMetadata.get(param - 1);
} else {
// Note row 1 is the 'return value' meta data
- paramFound = procMetadata.size() > param;
- if (paramFound) {
- return procMetadata.get(param);
- }
+ return procMetadata.get(param);
}
- if (!paramFound) {
+ }
+
+ private boolean isValidParamProc(int n) {
+ // Note row 1 is the 'return value' meta data
+ return ((stmtParent.bReturnValueSyntax && isTVP && procMetadata.size() >= n) || procMetadata.size() > n);
+ }
+
+ private boolean isValidParamQuery(int n) {
+ return (null != queryMetaMap && queryMetaMap.containsKey(n));
+ }
+
+ /**
+ * Checks if the @param passed is valid for either procedure metadata or query metadata.
+ *
+ * @param param
+ * @throws SQLServerException
+ */
+ private void checkParam(int param) throws SQLServerException {
+ // Check if Procedure Metadata is not available
+ if (null == procMetadata) {
+ // Check if Query Metadata is also not available
+ if (!isValidParamQuery(param)) {
+ SQLServerException.makeFromDriverError(con, stmtParent, SQLServerException.getErrString("R_noMetadata"),
+ null, false);
+ }
+ } else if (!isValidParamProc(param)) {
+ // Throw exception if @param index not found
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidParameterNumber"));
Object[] msgArgs = {param};
SQLServerException.makeFromDriverError(con, stmtParent, form.format(msgArgs), null, false);
}
- return null;
- }
-
- private void checkParam(int n) throws SQLServerException {
- if (!queryMetaMap.containsKey(n)) {
- SQLServerException.makeFromDriverError(con, stmtParent, SQLServerException.getErrString("R_noMetadata"),
- null, false);
- }
}
@Override
public String getParameterClassName(int param) throws SQLServerException {
checkClosed();
+ checkParam(param);
try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
+ if (null == procMetadata) {
return queryMetaMap.get(param).parameterClassName;
} else {
- JDBCType jdbcType = JDBCType.of((short) getParameterInfo(param).get("DATA_TYPE"));
- return jdbcType.className();
+ return JDBCType.of((short) getParameterInfo(param).get("DATA_TYPE")).className();
}
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
+ } catch (SQLServerException e) {
+ SQLServerException.makeFromDriverError(con, stmtParent, e.getMessage(), null, false);
return null;
}
}
@@ -753,8 +761,7 @@ public String getParameterClassName(int param) throws SQLServerException {
@Override
public int getParameterCount() throws SQLServerException {
checkClosed();
- if (procMetadata == null) {
- // PreparedStatement
+ if (null == procMetadata) {
return queryMetaMap.size();
} else {
// Row 1 is Return Type metadata
@@ -765,139 +772,92 @@ public int getParameterCount() throws SQLServerException {
@Override
public int getParameterMode(int param) throws SQLServerException {
checkClosed();
- try {
- if (procMetadata == null) {
- checkParam(param);
- // if it is not a stored proc, the param can only be input.
+ checkParam(param);
+ if (null == procMetadata) {
+ // if it is not a stored procedure, the @param can only be input.
+ return parameterModeIn;
+ } else {
+ int n = (int) getParameterInfo(param).get("COLUMN_TYPE");
+ if (n == 1)
return parameterModeIn;
- } else {
- int n = (int) getParameterInfo(param).get("COLUMN_TYPE");
- switch (n) {
- case 1:
- return parameterModeIn;
- case 2:
- return parameterModeOut;
- default:
- return parameterModeUnknown;
- }
- }
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return parameterModeUnknown;
+ else if (n == 2)
+ return parameterModeOut;
+ else
+ return parameterModeUnknown;
}
}
@Override
public int getParameterType(int param) throws SQLServerException {
checkClosed();
+ checkParam(param);
int parameterType = 0;
- try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
- parameterType = queryMetaMap.get(param).parameterType;
- } else {
- Map info = getParameterInfo(param);
- if (null != info) {
- parameterType = (short) info.get("DATA_TYPE");
- }
- }
- if (0 != parameterType) {
- switch (parameterType) {
- case microsoft.sql.Types.DATETIME:
- case microsoft.sql.Types.SMALLDATETIME:
- parameterType = SSType.DATETIME2.getJDBCType().asJavaSqlType();
- break;
- case microsoft.sql.Types.MONEY:
- case microsoft.sql.Types.SMALLMONEY:
- parameterType = SSType.DECIMAL.getJDBCType().asJavaSqlType();
- break;
- case microsoft.sql.Types.GUID:
- parameterType = SSType.CHAR.getJDBCType().asJavaSqlType();
- break;
- default:
- break;
- }
+ if (null == procMetadata) {
+ parameterType = queryMetaMap.get(param).parameterType;
+ } else {
+ parameterType = (short) getParameterInfo(param).get("DATA_TYPE");
+ }
+ if (0 != parameterType) {
+ switch (parameterType) {
+ case microsoft.sql.Types.DATETIME:
+ case microsoft.sql.Types.SMALLDATETIME:
+ parameterType = SSType.DATETIME2.getJDBCType().asJavaSqlType();
+ break;
+ case microsoft.sql.Types.MONEY:
+ case microsoft.sql.Types.SMALLMONEY:
+ parameterType = SSType.DECIMAL.getJDBCType().asJavaSqlType();
+ break;
+ case microsoft.sql.Types.GUID:
+ parameterType = SSType.CHAR.getJDBCType().asJavaSqlType();
+ break;
+ default:
+ break;
}
- return parameterType;
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return 0;
}
+ return parameterType;
}
@Override
public String getParameterTypeName(int param) throws SQLServerException {
checkClosed();
- try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
- return queryMetaMap.get(param).parameterTypeName;
- } else {
- return getParameterInfo(param).get("TYPE_NAME").toString();
- }
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return null;
+ checkParam(param);
+ if (null == procMetadata) {
+ return queryMetaMap.get(param).parameterTypeName;
+ } else {
+ return getParameterInfo(param).get("TYPE_NAME").toString();
}
}
@Override
public int getPrecision(int param) throws SQLServerException {
checkClosed();
- try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
- return queryMetaMap.get(param).precision;
- } else {
- int nPrec = (int) getParameterInfo(param).get("PRECISION");
- return nPrec;
- }
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return 0;
+ checkParam(param);
+ if (null == procMetadata) {
+ return queryMetaMap.get(param).precision;
+ } else {
+ return (int) getParameterInfo(param).get("PRECISION");
}
}
@Override
public int getScale(int param) throws SQLServerException {
checkClosed();
- try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
- return queryMetaMap.get(param).scale;
- } else {
- int nScale = (int) getParameterInfo(param).get("SCALE");
- return nScale;
- }
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return 0;
+ checkParam(param);
+ if (null == procMetadata) {
+ return queryMetaMap.get(param).scale;
+ } else {
+ return (int) getParameterInfo(param).get("SCALE");
}
}
@Override
public int isNullable(int param) throws SQLServerException {
checkClosed();
- try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
- return queryMetaMap.get(param).isNullable;
- } else {
- int nNull = (int) getParameterInfo(param).get("NULLABLE");
- if (nNull == 1)
- return parameterNullable;
- if (nNull == 0)
- return parameterNoNulls;
- return parameterNullableUnknown;
- }
- } catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
- return parameterNoNulls;
+ checkParam(param);
+ if (procMetadata == null) {
+ return queryMetaMap.get(param).isNullable;
+ } else {
+ return (int) getParameterInfo(param).get("NULLABLE");
}
}
@@ -905,7 +865,7 @@ public int isNullable(int param) throws SQLServerException {
* Returns if a supplied parameter index is valid.
*
* @param param
- * the param index
+ * the @param index
* @throws SQLServerException
* when an error occurs
* @return boolean
@@ -913,22 +873,22 @@ public int isNullable(int param) throws SQLServerException {
@Override
public boolean isSigned(int param) throws SQLServerException {
checkClosed();
+ checkParam(param);
try {
- if (procMetadata == null) {
- // PreparedStatement.
- checkParam(param);
+ if (null == procMetadata) {
return queryMetaMap.get(param).isSigned;
} else {
return JDBCType.of((short) getParameterInfo(param).get("DATA_TYPE")).isSigned();
}
} catch (SQLException e) {
- SQLServerException.makeFromDriverError(con, stmtParent, e.toString(), null, false);
+ SQLServerException.makeFromDriverError(con, stmtParent, e.getMessage(), null, false);
return false;
}
}
String getTVPSchemaFromStoredProcedure(int param) throws SQLServerException {
checkClosed();
+ checkParam(param);
return (String) getParameterInfo(param).get("SS_TYPE_SCHEMA_NAME");
}
}
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java
index d9e412515..aba77f885 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerResultSetMetaData.java
@@ -21,7 +21,7 @@ public final class SQLServerResultSetMetaData implements ISQLServerResultSetMeta
* Always update serialVersionUID when prompted.
*/
private static final long serialVersionUID = -5747558730471411712L;
-
+
private SQLServerConnection con;
private final SQLServerResultSet rs;
static final private java.util.logging.Logger logger = java.util.logging.Logger
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java
index fa6552d86..09c38dd74 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerSavepoint.java
@@ -21,7 +21,7 @@ public final class SQLServerSavepoint implements ISQLServerSavepoint {
* Always update serialVersionUID when prompted.
*/
private static final long serialVersionUID = 1857415943191289598L;
-
+
private final String sName;
private final int nId;
private final SQLServerConnection con;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
index 3db1126d2..262240bfd 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerStatement.java
@@ -54,7 +54,7 @@ public class SQLServerStatement implements ISQLServerStatement {
* Always update serialVersionUID when prompted.
*/
private static final long serialVersionUID = -4421134713913331507L;
-
+
final static char LEFT_CURLY_BRACKET = 123;
final static char RIGHT_CURLY_BRACKET = 125;
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
index 82f4a3813..1fa481f8f 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/dtv.java
@@ -738,11 +738,16 @@ private void sendTemporal(DTV dtv, JavaType javaType, Object value) throws SQLSe
if (null != typeInfo) // updater
{
switch (typeInfo.getSSType()) {
+ case DATETIME:
case DATETIME2:
- // Default and max fractional precision is 7 digits (100ns)
+ /* Default and max fractional precision is 7 digits (100ns)
+ * Send DateTime2 to DateTime columns to let the server handle nanosecond rounding. Also
+ * adjust scale accordingly to avoid rounding on driver's end.
+ */
+ int scale = (typeInfo.getSSType() == SSType.DATETIME) ? typeInfo.getScale() + 4 : typeInfo.getScale();
tdsWriter.writeRPCDateTime2(name,
timestampNormalizedCalendar(calendar, javaType, conn.baseYear()), subSecondNanos,
- typeInfo.getScale(), isOutParam);
+ scale, isOutParam);
break;
@@ -773,7 +778,6 @@ private void sendTemporal(DTV dtv, JavaType javaType, Object value) throws SQLSe
break;
- case DATETIME:
case SMALLDATETIME:
tdsWriter.writeRPCDateTime(name,
timestampNormalizedCalendar(calendar, javaType, conn.baseYear()), subSecondNanos,
diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java
index 4e07bc6b5..3cd436107 100644
--- a/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java
+++ b/src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java
@@ -255,8 +255,8 @@ boolean onTabName(TDSReader tdsReader) throws SQLServerException {
void onEOF(TDSReader tdsReader) throws SQLServerException {
if (null != getDatabaseError()) {
- SQLServerException.makeFromDatabaseError(tdsReader.getConnection(), null, getDatabaseError().getErrorMessage(),
- getDatabaseError(), false);
+ SQLServerException.makeFromDatabaseError(tdsReader.getConnection(), null,
+ getDatabaseError().getErrorMessage(), getDatabaseError(), false);
}
}
diff --git a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Linked.java b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Linked.java
new file mode 100644
index 000000000..21fbc533f
--- /dev/null
+++ b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/Linked.java
@@ -0,0 +1,27 @@
+package mssql.googlecode.concurrentlinkedhashmap;
+
+import java.util.Deque;
+
+/**
+ * An element that is linked on the {@link Deque}.
+ */
+interface Linked> {
+
+ /**
+ * Retrieves the previous element or null if either the element is
+ * unlinked or the first element on the deque.
+ */
+ T getPrevious();
+
+ /** Sets the previous element or null if there is no link. */
+ void setPrevious(T prev);
+
+ /**
+ * Retrieves the next element or null if either the element is
+ * unlinked or the last element on the deque.
+ */
+ T getNext();
+
+ /** Sets the next element or null if there is no link. */
+ void setNext(T next);
+}
diff --git a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/LinkedDeque.java b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/LinkedDeque.java
index 2bb23ea78..ffa048c9f 100644
--- a/src/main/java/mssql/googlecode/concurrentlinkedhashmap/LinkedDeque.java
+++ b/src/main/java/mssql/googlecode/concurrentlinkedhashmap/LinkedDeque.java
@@ -434,27 +434,3 @@ public void remove() {
abstract E computeNext();
}
}
-
-/**
- * An element that is linked on the {@link Deque}.
- */
-interface Linked> {
-
- /**
- * Retrieves the previous element or null if either the element is
- * unlinked or the first element on the deque.
- */
- T getPrevious();
-
- /** Sets the previous element or null if there is no link. */
- void setPrevious(T prev);
-
- /**
- * Retrieves the next element or null if either the element is
- * unlinked or the last element on the deque.
- */
- T getNext();
-
- /** Sets the next element or null if there is no link. */
- void setNext(T next);
-}
diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
index 2a5fd18fc..e4ead7fd5 100644
--- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
+++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java
@@ -12,15 +12,15 @@
import java.io.FileReader;
import java.io.IOException;
import java.math.BigDecimal;
+import java.sql.Connection;
import java.sql.Date;
-import java.sql.DriverManager;
import java.sql.JDBCType;
import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.LinkedList;
import java.util.Properties;
-import java.util.UUID;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
@@ -29,7 +29,6 @@
import org.opentest4j.TestAbortedException;
import com.microsoft.sqlserver.jdbc.RandomData;
-import com.microsoft.sqlserver.jdbc.RandomUtil;
import com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionJavaKeyStoreProvider;
import com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionKeyStoreProvider;
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
@@ -40,7 +39,9 @@
import com.microsoft.sqlserver.jdbc.TestUtils;
import com.microsoft.sqlserver.testframework.AbstractSQLGenerator;
import com.microsoft.sqlserver.testframework.AbstractTest;
+import com.microsoft.sqlserver.testframework.Constants;
import com.microsoft.sqlserver.testframework.DBConnection;
+import com.microsoft.sqlserver.testframework.PrepUtil;
import microsoft.sql.DateTimeOffset;
@@ -54,26 +55,11 @@
@RunWith(JUnitPlatform.class)
public class AESetup extends AbstractTest {
- static final String javaKeyStoreInputFile = "JavaKeyStore.txt";
- static final String keyStoreName = "MSSQL_JAVA_KEYSTORE";
- static final String jksName = "clientcert.jks";
- static final String cmkName = "JDBC_CMK";
- static final String cekName = "JDBC_CEK";
- static final String secretstrJks = "password";
-
- static String charTable = RandomUtil.getIdentifier("JDBCEncryptedChar");
- static String binaryTable = RandomUtil.getIdentifier("JDBCEncryptedBinary");
- static String dateTable = RandomUtil.getIdentifier("JDBCEncryptedDate");
- static String numericTable = RandomUtil.getIdentifier("JDBCEncryptedNumeric");
- static String scaleDateTable = RandomUtil.getIdentifier("JDBCEncryptedScaleDate");
-
- static final String uid = UUID.randomUUID().toString();
-
static String filePath = null;
static String thumbprint = null;
static String keyPath = null;
static String javaKeyAliases = null;
- static String OS = System.getProperty("os.name").toLowerCase();
+
static SQLServerColumnEncryptionKeyStoreProvider storeProvider = null;
static SQLServerStatementColumnEncryptionSetting stmtColEncSetting = null;
static String AETestConnectionString;
@@ -93,24 +79,24 @@ public static void setUpConnection() throws TestAbortedException, Exception {
}
AETestConnectionString = connectionString + ";sendTimeAsDateTime=false";
- readFromFile(javaKeyStoreInputFile, "Alias name");
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString);
+ readFromFile(Constants.JAVA_KEY_STORE_FILENAME, "Alias name");
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString);
SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
dropCEK(stmt);
dropCMK(stmt);
}
- keyPath = TestUtils.getCurrentClassPath() + jksName;
- storeProvider = new SQLServerColumnEncryptionJavaKeyStoreProvider(keyPath, secretstrJks.toCharArray());
+ keyPath = TestUtils.getCurrentClassPath() + Constants.JKS_NAME;
+ storeProvider = new SQLServerColumnEncryptionJavaKeyStoreProvider(keyPath, Constants.JKS_SECRET.toCharArray());
stmtColEncSetting = SQLServerStatementColumnEncryptionSetting.Enabled;
AEInfo = new Properties();
- AEInfo.setProperty("ColumnEncryptionSetting", "Enabled");
- AEInfo.setProperty("keyStoreAuthentication", "JavaKeyStorePassword");
+ AEInfo.setProperty("ColumnEncryptionSetting", Constants.ENABLED);
+ AEInfo.setProperty("keyStoreAuthentication", Constants.JAVA_KEY_STORE_PASSWORD);
AEInfo.setProperty("keyStoreLocation", keyPath);
- AEInfo.setProperty("keyStoreSecret", secretstrJks);
+ AEInfo.setProperty("keyStoreSecret", Constants.JKS_SECRET);
- createCMK(keyStoreName, javaKeyAliases);
+ createCMK(Constants.JAVA_KEY_STORE_NAME, javaKeyAliases);
createCEK(storeProvider);
}
@@ -126,8 +112,7 @@ public static void dropAll() throws Exception {
assumeTrue(13 <= con.getServerVersion(), TestResource.getResource("R_Incompat_SQLServerVersion"));
}
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(connectionString);
- SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (Connection con = getConnection(); Statement stmt = con.createStatement()) {
dropTables(stmt);
dropCEK(stmt);
dropCMK(stmt);
@@ -160,7 +145,7 @@ private static void readFromFile(String inputFile, String lookupValue) throws IO
}
}
} catch (IOException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -170,45 +155,45 @@ private static void readFromFile(String inputFile, String lookupValue) throws IO
* @throws SQLException
*/
protected static void createBinaryTable() throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(binaryTable) + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.BINARY_TABLE_AE) + " ("
+ "PlainBinary binary(20) null,"
+ "RandomizedBinary binary(20) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicBinary binary(20) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainVarbinary varbinary(50) null,"
+ "RandomizedVarbinary varbinary(50) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicVarbinary varbinary(50) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainVarbinaryMax varbinary(max) null,"
+ "RandomizedVarbinaryMax varbinary(max) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicVarbinaryMax varbinary(max) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainBinary512 binary(512) null,"
+ "RandomizedBinary512 binary(512) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicBinary512 binary(512) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainBinary8000 varbinary(8000) null,"
+ "RandomizedBinary8000 varbinary(8000) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicBinary8000 varbinary(8000) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -218,69 +203,69 @@ protected static void createBinaryTable() throws SQLException {
* @throws SQLException
*/
protected static void createCharTable() throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(charTable) + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.CHAR_TABLE_AE) + " ("
+ "PlainChar char(20) null,"
+ "RandomizedChar char(20) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicChar char(20) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainVarchar varchar(50) null,"
+ "RandomizedVarchar varchar(50) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicVarchar varchar(50) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainVarcharMax varchar(max) null,"
+ "RandomizedVarcharMax varchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicVarcharMax varchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNchar nchar(30) null,"
+ "RandomizedNchar nchar(30) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNchar nchar(30) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNvarchar nvarchar(60) null,"
+ "RandomizedNvarchar nvarchar(60) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNvarchar nvarchar(60) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNvarcharMax nvarchar(max) null,"
+ "RandomizedNvarcharMax nvarchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNvarcharMax nvarchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainUniqueidentifier uniqueidentifier null,"
+ "RandomizedUniqueidentifier uniqueidentifier ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicUniqueidentifier uniqueidentifier ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainVarchar8000 varchar(8000) null,"
+ "RandomizedVarchar8000 varchar(8000) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicVarchar8000 varchar(8000) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNvarchar4000 nvarchar(4000) null,"
+ "RandomizedNvarchar4000 nvarchar(4000) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNvarchar4000 nvarchar(4000) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -290,50 +275,51 @@ protected static void createCharTable() throws SQLException {
* @throws SQLException
*/
protected void createDateTable() throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(dateTable) + " (" + "PlainDate date null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.DATE_TABLE_AE) + " ("
+ + "PlainDate date null,"
+ "RandomizedDate date ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDate date ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDatetime2Default datetime2 null,"
+ "RandomizedDatetime2Default datetime2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetime2Default datetime2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDatetimeoffsetDefault datetimeoffset null,"
+ "RandomizedDatetimeoffsetDefault datetimeoffset ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetimeoffsetDefault datetimeoffset ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainTimeDefault time null,"
+ "RandomizedTimeDefault time ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicTimeDefault time ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDatetime datetime null,"
+ "RandomizedDatetime datetime ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetime datetime ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainSmalldatetime smalldatetime null,"
+ "RandomizedSmalldatetime smalldatetime ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicSmalldatetime smalldatetime ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -343,58 +329,58 @@ protected void createDateTable() throws SQLException {
* @throws SQLException
*/
protected void createDatePrecisionTable(int scale) throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(dateTable) + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.DATE_TABLE_AE) + " ("
// 1
+ "PlainDatetime2 datetime2(" + scale + ") null," + "RandomizedDatetime2 datetime2(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicDatetime2 datetime2(" + scale
+ + Constants.CEK_NAME + ") NULL," + "DeterministicDatetime2 datetime2(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
// 4
+ "PlainDatetime2Default datetime2 null,"
+ "RandomizedDatetime2Default datetime2 ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetime2Default datetime2 ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
// 7
+ "PlainDatetimeoffsetDefault datetimeoffset null,"
+ "RandomizedDatetimeoffsetDefault datetimeoffset ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetimeoffsetDefault datetimeoffset ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
// 10
+ "PlainTimeDefault time null,"
+ "RandomizedTimeDefault time ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicTimeDefault time ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
// 13
+ "PlainTime time(" + scale + ") null," + "RandomizedTime time(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicTime time(" + scale
+ + Constants.CEK_NAME + ") NULL," + "DeterministicTime time(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
// 16
+ "PlainDatetimeoffset datetimeoffset(" + scale + ") null," + "RandomizedDatetimeoffset datetimeoffset("
+ scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicDatetimeoffset datetimeoffset(" + scale
+ + Constants.CEK_NAME + ") NULL," + "DeterministicDatetimeoffset datetimeoffset(" + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -404,34 +390,34 @@ protected void createDatePrecisionTable(int scale) throws SQLException {
* @throws SQLException
*/
protected static void createDateScaleTable() throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(scaleDateTable) + " ("
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.SCALE_DATE_TABLE_AE) + " ("
+ "PlainDatetime2 datetime2(2) null,"
+ "RandomizedDatetime2 datetime2(2) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetime2 datetime2(2) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainTime time(2) null,"
+ "RandomizedTime time(2) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicTime time(2) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDatetimeoffset datetimeoffset(2) null,"
+ "RandomizedDatetimeoffset datetimeoffset(2) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDatetimeoffset datetimeoffset(2) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -441,110 +427,111 @@ protected static void createDateScaleTable() throws SQLException {
* @throws SQLException
*/
protected static void createNumericTable() throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(numericTable) + " (" + "PlainBit bit null,"
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.NUMERIC_TABLE_AE) + " ("
+ + "PlainBit bit null,"
+ "RandomizedBit bit ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicBit bit ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainTinyint tinyint null,"
+ "RandomizedTinyint tinyint ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicTinyint tinyint ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainSmallint smallint null,"
+ "RandomizedSmallint smallint ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicSmallint smallint ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainInt int null,"
+ "RandomizedInt int ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicInt int ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainBigint bigint null,"
+ "RandomizedBigint bigint ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicBigint bigint ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainFloatDefault float null,"
+ "RandomizedFloatDefault float ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicFloatDefault float ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainFloat float(30) null,"
+ "RandomizedFloat float(30) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicFloat float(30) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainReal real null,"
+ "RandomizedReal real ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicReal real ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDecimalDefault decimal null,"
+ "RandomizedDecimalDefault decimal ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDecimalDefault decimal ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDecimal decimal(10,5) null,"
+ "RandomizedDecimal decimal(10,5) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDecimal decimal(10,5) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNumericDefault numeric null,"
+ "RandomizedNumericDefault numeric ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNumericDefault numeric ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNumeric numeric(8,2) null,"
+ "RandomizedNumeric numeric(8,2) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNumeric numeric(8,2) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainSmallMoney smallmoney null,"
+ "RandomizedSmallMoney smallmoney ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicSmallMoney smallmoney ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainMoney money null,"
+ "RandomizedMoney money ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicMoney money ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDecimal2 decimal(28,4) null,"
+ "RandomizedDecimal2 decimal(28,4) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicDecimal2 decimal(28,4) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNumeric2 numeric(28,4) null,"
+ "RandomizedNumeric2 numeric(28,4) ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "DeterministicNumeric2 numeric(28,4) ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -554,35 +541,35 @@ protected static void createNumericTable() throws SQLException {
* @throws SQLException
*/
protected void createNumericPrecisionTable(int floatPrecision, int precision, int scale) throws SQLException {
- String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(numericTable) + " (" + "PlainFloat float("
- + floatPrecision + ") null," + "RandomizedFloat float(" + floatPrecision
+ String sql = "create table " + AbstractSQLGenerator.escapeIdentifier(Constants.NUMERIC_TABLE_AE) + " ("
+ + "PlainFloat float(" + floatPrecision + ") null," + "RandomizedFloat float(" + floatPrecision
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicFloat float(" + floatPrecision
+ + Constants.CEK_NAME + ") NULL," + "DeterministicFloat float(" + floatPrecision
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainDecimal decimal(" + precision + "," + scale + ") null," + "RandomizedDecimal decimal("
+ precision + "," + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicDecimal decimal(" + precision + "," + scale
+ + Constants.CEK_NAME + ") NULL," + "DeterministicDecimal decimal(" + precision + "," + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL,"
+ + Constants.CEK_NAME + ") NULL,"
+ "PlainNumeric numeric(" + precision + "," + scale + ") null," + "RandomizedNumeric numeric("
+ precision + "," + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = RANDOMIZED, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL," + "DeterministicNumeric numeric(" + precision + "," + scale
+ + Constants.CEK_NAME + ") NULL," + "DeterministicNumeric numeric(" + precision + "," + scale
+ ") ENCRYPTED WITH (ENCRYPTION_TYPE = DETERMINISTIC, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = "
- + cekName + ") NULL"
+ + Constants.CEK_NAME + ") NULL"
+ ");";
- try (SQLServerConnection con = (SQLServerConnection) DriverManager.getConnection(AETestConnectionString,
- AEInfo); SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
+ try (SQLServerConnection con = (SQLServerConnection) PrepUtil.getConnection(AETestConnectionString, AEInfo);
+ SQLServerStatement stmt = (SQLServerStatement) con.createStatement()) {
stmt.execute(sql);
stmt.execute("DBCC FREEPROCCACHE");
} catch (SQLException e) {
- fail(e.toString());
+ fail(e.getMessage());
}
}
@@ -629,8 +616,8 @@ protected static String[] createCharValues(boolean nullable) {
String varchar8000 = RandomData.generateCharTypes("8000", nullable, encrypted);
String nvarchar4000 = RandomData.generateNCharTypes("4000", nullable, encrypted);
- String[] values = {char20.trim(), varchar50, varcharmax, nchar30, nvarchar60, nvarcharmax, uid, varchar8000,
- nvarchar4000};
+ String[] values = {char20.trim(), varchar50, varcharmax, nchar30, nvarchar60, nvarcharmax, Constants.UID,
+ varchar8000, nvarchar4000};
return values;
}
@@ -700,12 +687,12 @@ protected static LinkedList