Skip to content

Commit 03fcd0a

Browse files
authored
Fixes for 9.4.1 Hotfix (#1700)
1 parent a901c34 commit 03fcd0a

File tree

10 files changed

+206
-30
lines changed

10 files changed

+206
-30
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ All notable changes to this project will be documented in this file.
33

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

6+
## [9.4.1] HotFix & Stable Release
7+
### Fixed issues
8+
- Fixed TDSParser stuck on TDS_COLMETADATA issue [#1662] (https://github.com/microsoft/mssql-jdbc/pull/1662)
9+
- Fixed conversion of LocalDateTime and LocalTime to String in Bulk Copy [#1640] (https://github.com/microsoft/mssql-jdbc/pull/1640)
10+
611
## [9.4.0] Stable Release
712
### Added
813
- Added JAVA 16 support [#1579](https://github.com/microsoft/mssql-jdbc/pull/1579)
9-
- Added optional realm connection string property for Kerberos authenticatoin [#1581](https://github.com/microsoft/mssql-jdbc/pull/1581)
14+
- Added optional realm connection string property for Kerberos authentication [#1581](https://github.com/microsoft/mssql-jdbc/pull/1581)
1015
- Added support for multiple, successive connections using AKV provider [#1594](https://github.com/microsoft/mssql-jdbc/pull/1594)
1116
- Updated error messages for Enclave exceptions with forward link to troubleshooting guide [#1585](https://github.com/microsoft/mssql-jdbc/pull/1585)
1217
- Added driver version to the database during prelogin [#1583](https://github.com/microsoft/mssql-jdbc/pull/1583)

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
8080
<dependency>
8181
<groupId>com.microsoft.sqlserver</groupId>
8282
<artifactId>mssql-jdbc</artifactId>
83-
<version>9.4.0.jre16</version>
83+
<version>9.4.1.jre16</version>
8484
</dependency>
8585
```
8686
The driver can be downloaded from the [Microsoft Download Center](https://go.microsoft.com/fwlink/?linkid=2168495).
@@ -91,7 +91,7 @@ To get the latest preview version of the driver, add the following to your POM f
9191
<dependency>
9292
<groupId>com.microsoft.sqlserver</groupId>
9393
<artifactId>mssql-jdbc</artifactId>
94-
<version>9.4.0.jre16</version>
94+
<version>9.4.1.jre16</version>
9595
</dependency>
9696
```
9797

@@ -126,7 +126,7 @@ Projects that require either of the two features need to explicitly declare the
126126
<dependency>
127127
<groupId>com.microsoft.sqlserver</groupId>
128128
<artifactId>mssql-jdbc</artifactId>
129-
<version>9.4.0.jre16</version>
129+
<version>9.4.1.jre16</version>
130130
<scope>compile</scope>
131131
</dependency>
132132

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

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

177177
<dependency>

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
name: authDLL
3939
displayName: 'Download mssql-jdbc_auth DLL'
4040
inputs:
41-
secureFile: 'mssql-jdbc_auth-9.4.0.x64.dll'
41+
secureFile: 'mssql-jdbc_auth-9.4.1.x64.dll'
4242
- task: Maven@3
4343
displayName: 'Maven build jre16'
4444
inputs:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
apply plugin: 'java'
1616

17-
version = '9.4.0'
17+
version = '9.4.1'
1818
def jreVersion = ""
1919
def testOutputDir = file("build/classes/java/test")
2020
def archivesBaseName = 'mssql-jdbc'

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.microsoft.sqlserver</groupId>
88
<artifactId>mssql-jdbc</artifactId>
9-
<version>9.4.0</version>
9+
<version>9.4.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Microsoft JDBC Driver for SQL Server</name>

src/main/java/com/microsoft/sqlserver/jdbc/SQLJdbcVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
final class SQLJdbcVersion {
99
static final int major = 9;
1010
static final int minor = 4;
11-
static final int patch = 0;
11+
static final int patch = 1;
1212
static final int build = 0;
1313
/*
1414
* Used to load mssql-jdbc_auth DLL.

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,21 +2292,23 @@ else if (null != sourceCryptoMeta) {
22922292
if (null == colValue) {
22932293
writeNullToTdsWriter(tdsWriter, bulkJdbcType, isStreaming);
22942294
} else {
2295-
String colValueStr = colValue.toString();
22962295

2297-
// Remove extra trailing zeros added from toString
2298-
if (colValue instanceof LocalDateTime || colValue instanceof LocalTime) {
2299-
colValueStr = colValueStr.contains(".") ? colValueStr.replaceAll("0*$", "")
2300-
: colValueStr;
2296+
String colValueStr;
2297+
if (colValue instanceof LocalDateTime) {
2298+
colValueStr = ((LocalDateTime)colValue).format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
2299+
} else if (colValue instanceof LocalTime) {
2300+
colValueStr = ((LocalTime)colValue).format(DateTimeFormatter.ISO_LOCAL_TIME);
2301+
} else {
2302+
colValueStr = colValue.toString();
23012303
}
23022304

23032305
if (unicodeConversionRequired(bulkJdbcType, destSSType)) {
2304-
int stringLength = colValue.toString().length();
2306+
int stringLength = colValueStr.length();
23052307
byte[] typevarlen = new byte[2];
23062308
typevarlen[0] = (byte) (2 * stringLength & 0xFF);
23072309
typevarlen[1] = (byte) ((2 * stringLength >> 8) & 0xFF);
23082310
tdsWriter.writeBytes(typevarlen);
2309-
tdsWriter.writeString(colValue.toString());
2311+
tdsWriter.writeString(colValueStr);
23102312
} else {
23112313
if ((SSType.BINARY == destSSType) || (SSType.VARBINARY == destSSType)) {
23122314
byte[] bytes = null;

src/main/java/com/microsoft/sqlserver/jdbc/tdsparser.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,14 @@ boolean onOrder(TDSReader tdsReader) throws SQLServerException {
251251
}
252252

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

src/test/java/com/microsoft/sqlserver/jdbc/bulkCopy/BulkCopyISQLServerBulkRecordTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
package com.microsoft.sqlserver.jdbc.bulkCopy;
66

7-
import static org.junit.jupiter.api.Assertions.assertEquals;
87
import static org.junit.jupiter.api.Assertions.assertTrue;
98
import static org.junit.jupiter.api.Assertions.fail;
109

@@ -74,7 +73,6 @@ public void testISQLServerBulkRecord() throws SQLException {
7473
}
7574
}
7675

77-
7876
@Test
7977
public void testBulkCopyDateTimePrecision() throws SQLException {
8078
String dstTable = TestUtils
@@ -103,6 +101,7 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
103101
Constants.RANDOM.nextInt(60), Constants.RANDOM.nextInt(60), 123450000));
104102
LocalDateTime data7 = LocalDateTime.of(LocalDate.now(), LocalTime.of(Constants.RANDOM.nextInt(24),
105103
Constants.RANDOM.nextInt(60), Constants.RANDOM.nextInt(60), 123456000));
104+
LocalDateTime data8 = LocalDateTime.of(LocalDate.now(), LocalTime.of(0, 0, 0, 0));
106105
bulkCopy.writeToServer(new BulkRecordDT(data));
107106
bulkCopy.writeToServer(new BulkRecordDT(data1));
108107
bulkCopy.writeToServer(new BulkRecordDT(data2));
@@ -111,6 +110,7 @@ public void testBulkCopyDateTimePrecision() throws SQLException {
111110
bulkCopy.writeToServer(new BulkRecordDT(data5));
112111
bulkCopy.writeToServer(new BulkRecordDT(data6));
113112
bulkCopy.writeToServer(new BulkRecordDT(data7));
113+
bulkCopy.writeToServer(new BulkRecordDT(data8));
114114

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

135137
} catch (Exception e) {
136138
fail(e.getMessage());

0 commit comments

Comments
 (0)