Skip to content

Commit

Permalink
Merge dev into master for 8.3.1 Preview Release
Browse files Browse the repository at this point in the history
Merge dev into master for 8.3.1 Preview Release
  • Loading branch information
ulvii committed May 29, 2020
2 parents 93a2856 + 326a06a commit 9877ac5
Show file tree
Hide file tree
Showing 59 changed files with 1,964 additions and 1,193 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)

## [8.3.1] Preview Release
### Added
- Added delayed durability option to SQLServerConnection.commit() [#1310](https://github.com/microsoft/mssql-jdbc/pull/1310)
- Introduced SQLServerBulkCSVFileRecord.setEscapeColumnDelimitersCSV() to escape delimiters and double quotes when using bulk copy to load from CSV files [#1312](https://github.com/microsoft/mssql-jdbc/pull/1312)
- Added certificate expiry validation when using Always Encrypted with secure enclaves feature [#1321](https://github.com/microsoft/mssql-jdbc/pull/1321)
- Added SQL State to Exception when connection is closed [#1326](https://github.com/microsoft/mssql-jdbc/pull/1326)
- Introduced extended bulk copy support against Azure Data Warehouse [#1331](https://github.com/microsoft/mssql-jdbc/pull/1331)
- Introduced 'delayLoadingLobs' connection property to provide backward compatibility when streaming LOBs [#1336](https://github.com/microsoft/mssql-jdbc/pull/1336)

### Fixed issues
- Fixed an issue with MSI authentication failing due to expiry date format mismatch [#1308](https://github.com/microsoft/mssql-jdbc/pull/1308)
- Fixed an issue with streams not getting closed when using Always Encrypted with secure enclaves feature [#1315](https://github.com/microsoft/mssql-jdbc/pull/1315)
- Fixed an issue with retrieving SQL VARIANT as its underlying type [#1320](https://github.com/microsoft/mssql-jdbc/pull/1320)
- Fixed issues with the driver not being JAVA 8 compliant [#1328](https://github.com/microsoft/mssql-jdbc/pull/1328)
- Fixed an issue with PreparedStatement when inserting large spatial data types [#1337](https://github.com/microsoft/mssql-jdbc/pull/1337)

### Changed
- Updated driver and test dependencies [#1294](https://github.com/microsoft/mssql-jdbc/pull/1294), [#1313](https://github.com/microsoft/mssql-jdbc/pull/1313)
- Improved exception message when connecting to redirection-enabled Azure server [#1311](https://github.com/microsoft/mssql-jdbc/pull/1311)
- Improved performance when parsing connection string [#1317](https://github.com/microsoft/mssql-jdbc/pull/1317)
- Updated the driver to throw a warning when TLS version lower than 1.2 is negotiated [#1322](https://github.com/microsoft/mssql-jdbc/pull/1322)
- Removed unused code [#1330](https://github.com/microsoft/mssql-jdbc/pull/1330)

## [8.3.0] Preview Release
### Added
- Added connection properties to specify custom SocketFactory [#1217](https://github.com/Microsoft/mssql-jdbc/pull/1217)
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ To get the latest preview version of the driver, add the following to your POM f
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.0.jre14-preview</version>
<version>8.3.1.jre14-preview</version>
</dependency>
```

Expand Down Expand Up @@ -129,20 +129,20 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.0.jre14-preview</version>
<version>8.3.1.jre14-preview</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</dependency>

<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.7.0</version>
<version>1.7.4</version>
</dependency>
```

Expand All @@ -152,26 +152,26 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.0.jre14-preview</version>
<version>8.3.1.jre14-preview</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>adal4j</artifactId>
<version>1.6.4</version>
<version>1.6.5</version>
</dependency>

<dependency>
<groupId>com.microsoft.rest</groupId>
<artifactId>client-runtime</artifactId>
<version>1.7.0</version>
<version>1.7.4</version>
</dependency>

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.2.2</version>
<version>1.2.4</version>
</dependency>
```

Expand All @@ -185,7 +185,7 @@ When setting 'useFmtOnly' property to 'true' for establishing a connection or cr
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.0.jre14-preview</version>
<version>8.3.1.jre14-preview</version>
</dependency>

<dependency>
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

apply plugin: 'java'

version = '8.3.0'
version = '8.3.1'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
Expand Down Expand Up @@ -116,7 +116,8 @@ dependencies {
'com.microsoft.azure:adal4j:1.6.4',
'org.antlr:antlr4-runtime:4.7.2',
'com.google.code.gson:gson:2.8.6',
'org.bouncycastle:bcprov-jdk15on:1.64'
'org.bouncycastle:bcprov-jdk15on:1.64',
'org.bouncycastle:bcpkix-jdk15on:1.64'
testCompile 'org.junit.platform:junit-platform-console:1.5.2',
'org.junit.platform:junit-platform-commons:1.5.2',
'org.junit.platform:junit-platform-engine:1.5.2',
Expand Down
25 changes: 12 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.3.0</version>
<version>8.3.1</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down Expand Up @@ -54,28 +54,28 @@
clientCertAuth - - For tests requiring client certificate authentication setup (excluded by default)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default testing enabled with SQL Server 2019 (SQLv15) -->
<excludedGroups>xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth</excludedGroups>
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth</excludedGroups>

<!-- Use -preview for preview release, leave empty for official release.-->
<releaseExt>-preview</releaseExt>

<!-- Driver Dependencies -->
<azure.keyvault.version>1.2.2</azure.keyvault.version>
<azure.adal4j.version>1.6.4</azure.adal4j.version>
<rest.client.version>1.7.0</rest.client.version>
<azure.keyvault.version>1.2.4</azure.keyvault.version>
<azure.adal4j.version>1.6.5</azure.adal4j.version>
<rest.client.version>1.7.4</rest.client.version>
<osgi.core.version>6.0.0</osgi.core.version>
<osgi.comp.version>5.0.0</osgi.comp.version>
<antlr.runtime.version>4.7.2</antlr.runtime.version>
<google.gson.version>2.8.6</google.gson.version>
<bouncycastle.bcprov.version>1.64</bouncycastle.bcprov.version>
<bouncycastle.bcpkix.version>1.64</bouncycastle.bcpkix.version>
<bouncycastle.bcprov.version>1.65</bouncycastle.bcprov.version>
<bouncycastle.bcpkix.version>1.65</bouncycastle.bcpkix.version>

<!-- JUnit Test Dependencies -->
<junit.platform.version>[1.3.2, 1.5.2]</junit.platform.version>
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<hikaricp.version>3.4.1</hikaricp.version>
<hikaricp.version>3.4.2</hikaricp.version>
<dbcp2.version>2.7.0</dbcp2.version>
<slf4j.nop.version>1.7.29</slf4j.nop.version>
<slf4j.nop.version>1.7.30</slf4j.nop.version>
<gemini.mock.version>2.1.0.RELEASE</gemini.mock.version>
<h2.version>1.4.200</h2.version>

Expand Down Expand Up @@ -125,16 +125,13 @@
<version>${bouncycastle.bcprov.version}</version>
<optional>true</optional>
</dependency>

<!-- dependencies for Client Certificate Authentication -->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>${bouncycastle.bcpkix.version}</version>
<optional>true</optional>
</dependency>


<!-- dependencies provided by an OSGi-Framework -->
<dependency>
<groupId>org.osgi</groupId>
Expand Down Expand Up @@ -231,7 +228,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.0</version>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -278,6 +275,8 @@
<configuration>
<!-- Exclude [xJDBC42] For tests not compatible with JDBC 4.2 Specifications -->
<excludedGroups>${excludedGroups}, xJDBC42</excludedGroups>
<!-- needs to be overridden as illegal-access and MaxPermSize=256m not valid in java 8 -->
<argLine>-Xmx1024m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
60 changes: 50 additions & 10 deletions src/main/java/com/microsoft/sqlserver/jdbc/DDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


/**
* Utility class for all Data Dependant Conversions (DDC).
* Utility class for all Data Dependent Conversions (DDC).
*/

final class DDC {
Expand Down Expand Up @@ -72,6 +72,17 @@ static final Object convertIntegerToObject(int intValue, int valueLength, JDBCTy
return (float) intValue;
case BINARY:
return convertIntToBytes(intValue, valueLength);
case SQL_VARIANT:
// return short or bit if the underlying datatype of sql_variant is tinyint, smallint or bit
// otherwise, return integer
// Longer datatypes such as double and float are handled by convertLongToObject instead.
if (valueLength == 1) {
return 0 != intValue;
} else if (valueLength == 3 || valueLength == 4) {
return (short) intValue;
} else {
return intValue;
}
default:
return Integer.toString(intValue);
}
Expand All @@ -93,6 +104,7 @@ static final Object convertIntegerToObject(int intValue, int valueLength, JDBCTy
static final Object convertLongToObject(long longVal, JDBCType jdbcType, SSType baseSSType, StreamType streamType) {
switch (jdbcType) {
case BIGINT:
case SQL_VARIANT:
return longVal;
case INTEGER:
return (int) longVal;
Expand Down Expand Up @@ -209,6 +221,7 @@ static final byte[] convertIntToBytes(int intValue, int valueLength) {
static final Object convertFloatToObject(float floatVal, JDBCType jdbcType, StreamType streamType) {
switch (jdbcType) {
case REAL:
case SQL_VARIANT:
return floatVal;
case INTEGER:
return (int) floatVal;
Expand Down Expand Up @@ -266,6 +279,7 @@ static final Object convertDoubleToObject(double doubleVal, JDBCType jdbcType, S
switch (jdbcType) {
case FLOAT:
case DOUBLE:
case SQL_VARIANT:
return doubleVal;
case REAL:
return (Double.valueOf(doubleVal)).floatValue();
Expand Down Expand Up @@ -324,6 +338,30 @@ static final byte[] convertBigDecimalToBytes(BigDecimal bigDecimalVal, int scale
return valueBytes;
}

static final byte[] convertMoneyToBytes(BigDecimal bigDecimalVal, int bLength) {
byte[] valueBytes = new byte[bLength];

BigInteger bi = bigDecimalVal.unscaledValue();

if (bLength == 8) {
// money
byte[] longbArray = new byte[bLength];
Util.writeLong(bi.longValue(), longbArray, 0);
/*
* TDS 2.2.5.5.1.4 Fixed-Point Numbers Money is represented as a 8 byte signed integer, with one 4-byte
* integer that represents the more significant half, and one 4-byte integer that represents the less
* significant half.
*/
System.arraycopy(longbArray, 0, valueBytes, 4, 4);
System.arraycopy(longbArray, 4, valueBytes, 0, 4);
} else {
// smallmoney
Util.writeInt(bi.intValue(), valueBytes, 0);
}

return valueBytes;
}

/**
* Convert a BigDecimal object to desired target user type.
*
Expand All @@ -341,6 +379,7 @@ static final Object convertBigDecimalToObject(BigDecimal bigDecimalVal, JDBCType
case NUMERIC:
case MONEY:
case SMALLMONEY:
case SQL_VARIANT:
return bigDecimalVal;
case FLOAT:
case DOUBLE:
Expand Down Expand Up @@ -614,9 +653,9 @@ private static LocalDateTime parseStringIntoLDT(String s) {
if (firstDash > 0 && secondDash > 0 && secondDash < dividingSpace - 1) {
if (firstDash == YEAR_LENGTH && (secondDash - firstDash > 1 && secondDash - firstDash <= MONTH_LENGTH + 1)
&& (dividingSpace - secondDash > 1 && dividingSpace - secondDash <= DAY_LENGTH + 1)) {
year = Integer.parseInt(s, 0, firstDash, 10);
month = Integer.parseInt(s, firstDash + 1, secondDash, 10);
day = Integer.parseInt(s, secondDash + 1, dividingSpace, 10);
year = Integer.parseInt(s.substring(0, firstDash));
month = Integer.parseInt(s.substring(firstDash + 1, secondDash));
day = Integer.parseInt(s.substring(secondDash + 1, dividingSpace));

if ((month >= 1 && month <= MAX_MONTH) && (day >= 1 && day <= MAX_DAY)) {
parsedDate = true;
Expand All @@ -630,16 +669,16 @@ private static LocalDateTime parseStringIntoLDT(String s) {
// Convert the time; default missing nanos
int len = s.length();
if (firstColon > 0 && secondColon > 0 && secondColon < len - 1) {
hour = Integer.parseInt(s, dividingSpace + 1, firstColon, 10);
minute = Integer.parseInt(s, firstColon + 1, secondColon, 10);
hour = Integer.parseInt(s.substring(dividingSpace + 1, firstColon));
minute = Integer.parseInt(s.substring(firstColon + 1, secondColon));
if (period > 0 && period < len - 1) {
second = Integer.parseInt(s, secondColon + 1, period, 10);
second = Integer.parseInt(s.substring(secondColon + 1, period));
int nanoPrecision = len - (period + 1);
if (nanoPrecision > 9)
throw new java.lang.IllegalArgumentException(formatError);
if (!Character.isDigit(s.charAt(period + 1)))
throw new java.lang.IllegalArgumentException(formatError);
int tmpNanos = Integer.parseInt(s, period + 1, len, 10);
int tmpNanos = Integer.parseInt(s.substring(period + 1, len));
while (nanoPrecision < 9) {
tmpNanos *= 10;
nanoPrecision++;
Expand All @@ -648,7 +687,7 @@ private static LocalDateTime parseStringIntoLDT(String s) {
} else if (period > 0) {
throw new java.lang.IllegalArgumentException(formatError);
} else {
second = Integer.parseInt(s, secondColon + 1, len, 10);
second = Integer.parseInt(s.substring(secondColon + 1, len));
}
} else {
throw new java.lang.IllegalArgumentException(formatError);
Expand Down Expand Up @@ -1274,7 +1313,8 @@ private static Object convertTemporalToObject(JDBCType jdbcType, SSType ssType,

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));
java.sql.Timestamp.valueOf(ldt),
fractionalSecondsString(subSecondNanos, fractionalSecondsScale));
}

case DATETIME: // and SMALLDATETIME
Expand Down

0 comments on commit 9877ac5

Please sign in to comment.