Skip to content

Commit

Permalink
Fixes for 9.4.1 Hotfix (#1700)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilgreenbird authored Dec 2, 2021
1 parent a901c34 commit 03fcd0a
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 30 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ All notable changes to this project will be documented in this file.

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

## [9.4.1] HotFix & Stable Release
### Fixed issues
- Fixed TDSParser stuck on TDS_COLMETADATA issue [#1662] (https://github.com/microsoft/mssql-jdbc/pull/1662)
- Fixed conversion of LocalDateTime and LocalTime to String in Bulk Copy [#1640] (https://github.com/microsoft/mssql-jdbc/pull/1640)

## [9.4.0] Stable Release
### Added
- Added JAVA 16 support [#1579](https://github.com/microsoft/mssql-jdbc/pull/1579)
- Added optional realm connection string property for Kerberos authenticatoin [#1581](https://github.com/microsoft/mssql-jdbc/pull/1581)
- Added optional realm connection string property for Kerberos authentication [#1581](https://github.com/microsoft/mssql-jdbc/pull/1581)
- Added support for multiple, successive connections using AKV provider [#1594](https://github.com/microsoft/mssql-jdbc/pull/1594)
- Updated error messages for Enclave exceptions with forward link to troubleshooting guide [#1585](https://github.com/microsoft/mssql-jdbc/pull/1585)
- Added driver version to the database during prelogin [#1583](https://github.com/microsoft/mssql-jdbc/pull/1583)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre16</version>
<version>9.4.1.jre16</version>
</dependency>
```
The driver can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=2168495).
Expand All @@ -91,7 +91,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>9.4.0.jre16</version>
<version>9.4.1.jre16</version>
</dependency>
```

Expand Down Expand Up @@ -126,7 +126,7 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre16</version>
<version>9.4.1.jre16</version>
<scope>compile</scope>
</dependency>

Expand All @@ -144,7 +144,7 @@ Projects that require either of the two features need to explicitly declare the
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre16</version>
<version>9.4.1.jre16</version>
<scope>compile</scope>
</dependency>

Expand All @@ -171,7 +171,7 @@ When setting 'useFmtOnly' property to 'true' for establishing a connection or cr
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre16</version>
<version>9.4.1.jre16</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
name: authDLL
displayName: 'Download mssql-jdbc_auth DLL'
inputs:
secureFile: 'mssql-jdbc_auth-9.4.0.x64.dll'
secureFile: 'mssql-jdbc_auth-9.4.1.x64.dll'
- task: Maven@3
displayName: 'Maven build jre16'
inputs:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

apply plugin: 'java'

version = '9.4.0'
version = '9.4.1'
def jreVersion = ""
def testOutputDir = file("build/classes/java/test")
def archivesBaseName = 'mssql-jdbc'
Expand Down
2 changes: 1 addition & 1 deletion 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>9.4.0</version>
<version>9.4.1</version>
<packaging>jar</packaging>

<name>Microsoft JDBC Driver for SQL Server</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
final class SQLJdbcVersion {
static final int major = 9;
static final int minor = 4;
static final int patch = 0;
static final int patch = 1;
static final int build = 0;
/*
* Used to load mssql-jdbc_auth DLL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2292,21 +2292,23 @@ else if (null != sourceCryptoMeta) {
if (null == colValue) {
writeNullToTdsWriter(tdsWriter, bulkJdbcType, isStreaming);
} else {
String colValueStr = colValue.toString();

// Remove extra trailing zeros added from toString
if (colValue instanceof LocalDateTime || colValue instanceof LocalTime) {
colValueStr = colValueStr.contains(".") ? colValueStr.replaceAll("0*$", "")
: colValueStr;
String colValueStr;
if (colValue instanceof LocalDateTime) {
colValueStr = ((LocalDateTime)colValue).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
} else if (colValue instanceof LocalTime) {
colValueStr = ((LocalTime)colValue).format(DateTimeFormatter.ISO_LOCAL_TIME);
} else {
colValueStr = colValue.toString();
}

if (unicodeConversionRequired(bulkJdbcType, destSSType)) {
int stringLength = colValue.toString().length();
int stringLength = colValueStr.length();
byte[] typevarlen = new byte[2];
typevarlen[0] = (byte) (2 * stringLength & 0xFF);
typevarlen[1] = (byte) ((2 * stringLength >> 8) & 0xFF);
tdsWriter.writeBytes(typevarlen);
tdsWriter.writeString(colValue.toString());
tdsWriter.writeString(colValueStr);
} else {
if ((SSType.BINARY == destSSType) || (SSType.VARBINARY == destSSType)) {
byte[] bytes = null;
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,14 @@ boolean onOrder(TDSReader tdsReader) throws SQLServerException {
}

boolean onColMetaData(TDSReader tdsReader) throws SQLServerException {
// SHOWPLAN might be ON, instead of throwing an exception, ignore the column meta data
if (logger.isLoggable(Level.SEVERE))
logger.severe(tdsReader.toString() + ": " + logContext + ": Encountered "
+ TDS.getTokenName(tdsReader.peekTokenType()) + ". SHOWPLAN is ON, ignoring.");
/*
* SHOWPLAN or something else that produces extra metadata might be ON. instead of throwing an exception, warn
* and discard the column meta data
*/
if (logger.isLoggable(Level.WARNING))
logger.warning(tdsReader.toString() + ": " + logContext + ": Discarding unexpected "
+ TDS.getTokenName(tdsReader.peekTokenType()));
(new StreamColumns(false)).setFromTDS(tdsReader);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package com.microsoft.sqlserver.jdbc.bulkCopy;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -74,7 +73,6 @@ public void testISQLServerBulkRecord() throws SQLException {
}
}


@Test
public void testBulkCopyDateTimePrecision() throws SQLException {
String dstTable = TestUtils
Expand Down Expand Up @@ -103,6 +101,7 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
Constants.RANDOM.nextInt(60), Constants.RANDOM.nextInt(60), 123450000));
LocalDateTime data7 = LocalDateTime.of(LocalDate.now(), LocalTime.of(Constants.RANDOM.nextInt(24),
Constants.RANDOM.nextInt(60), Constants.RANDOM.nextInt(60), 123456000));
LocalDateTime data8 = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0, 0));
bulkCopy.writeToServer(new BulkRecordDT(data));
bulkCopy.writeToServer(new BulkRecordDT(data1));
bulkCopy.writeToServer(new BulkRecordDT(data2));
Expand All @@ -111,6 +110,7 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
bulkCopy.writeToServer(new BulkRecordDT(data5));
bulkCopy.writeToServer(new BulkRecordDT(data6));
bulkCopy.writeToServer(new BulkRecordDT(data7));
bulkCopy.writeToServer(new BulkRecordDT(data8));

String select = "SELECT * FROM " + dstTable + " order by Dataid";
ResultSet rs = dstStmt.executeQuery(select);
Expand All @@ -131,6 +131,8 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
assertTrue(data6.equals(rs.getObject(2, LocalDateTime.class)));
assertTrue(rs.next());
assertTrue(data7.equals(rs.getObject(2, LocalDateTime.class)));
assertTrue(rs.next());
assertTrue(data8.equals(rs.getObject(2, LocalDateTime.class)));

} catch (Exception e) {
fail(e.getMessage());
Expand Down
Loading

0 comments on commit 03fcd0a

Please sign in to comment.