Skip to content

Commit 5d62799

Browse files
author
Divang Sharma
committed
Merge remote-tracking branch 'origin/main' into dev/divang/handle_fatal_severity
2 parents e47d759 + d08ae78 commit 5d62799

40 files changed

+1633
-584
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,43 @@
22
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/)
5+
## [13.2.0] Stable Release
6+
7+
### Changed
8+
9+
- **Use sys.all_objects for accurate function and procedure filtering** [#2705](https://github.com/microsoft/mssql-jdbc/pull/2705)
10+
**What changed**: Differentiated stored procedures and functions using sys.all_objects instead of sp_stored_procedures.
11+
**Who benefits**: Developers using getProcedures() and getFunctions() in JDBC.
12+
**Impact**: Ensures correct metadata retrieval, preventing confusion from mixed results.
13+
14+
### Fixed issues
15+
16+
- **Fix trustStoreType JVM property consultation in SSL Connections** [#2724](https://github.com/microsoft/mssql-jdbc/pull/2724)
17+
**What was fixed**: Ensured fallback to JVM system property javax.net.ssl.trustStoreType if connection property is unset.
18+
**Who benefits**: Users configuring SSL via system properties.
19+
**Impact**: Enables proper SSL trust store resolution, improving compatibility with system configurations.
20+
21+
- **Addressed a data integrity and performance issue for bulk copy batch inserts with non-Unicode Strings** [#2735](https://github.com/microsoft/mssql-jdbc/pull/2735)
22+
**What was fixed**: Resolved performance degradation and incorrect string handling in bulk copy batch inserts when useBulkCopyForBatchInsert=true and sendStringParametersAsUnicode=false.
23+
**Who benefits**: Applications using SQL Server JDBC Bulk Copy for high-volume inserts, especially with non-Unicode or accented character data.
24+
**Impact**: Restores expected string storage, improves bulk insert performance for bulk copy API.
25+
26+
- **Handle SQL comments at start of query in getGenerateKeys() method** [#2731](https://github.com/microsoft/mssql-jdbc/pull/2731)
27+
**What was fixed**: Corrected detection of INSERT statements when preceded by SQL comments.
28+
**Who benefits**: Developers using getGeneratedKeys() after commented SQL inserts.
29+
**Impact**: Fixes previously failing key retrieval when comments are present before the query.
30+
31+
- **Fix update count handling for multi-statement queries executed via PreparedStatement execute method.** [#2737](https://github.com/microsoft/mssql-jdbc/pull/2737)
32+
**What was fixed**: Corrected update count handling for multi-statement queries run using PreparedStatement execute method, ensuring accurate counts for INSERT and other DML operations.
33+
**Who benefits**: Java applications using SQL Server JDBC with multi-statement PreparedStatement executions.
34+
**Impact**: Eliminates inconsistent update counts between Statement and PreparedStatement, improving reliability of result processing logic.
35+
36+
- **CodeQL suppression fixes** [#2728](https://github.com/microsoft/mssql-jdbc/pull/2728)
37+
**What was fixed**: Suppressed CodeQL rule [SM05141] with justification for broader usage scenarios.
38+
**Who benefits**: Developers maintaining code quality tools like CodeQL.
39+
**Impact**: Prevents unnecessary alerts for valid usage in multi-environment libraries.
40+
41+
542
## [13.1.1] Preview Release
643

744
### Added

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We're now on the Maven Central Repository. Add the following to your POM file to
8383
<dependency>
8484
<groupId>com.microsoft.sqlserver</groupId>
8585
<artifactId>mssql-jdbc</artifactId>
86-
<version>13.1.1.jre11-preview</version>
86+
<version>13.2.0.jre11</version>
8787
</dependency>
8888
```
8989
The driver can be downloaded from [Microsoft](https://aka.ms/downloadmssqljdbc). For driver version 12.1.0 and greater, please use the jre11 version when using Java 11 or greater, and the jre8 version when using Java 8.
@@ -94,7 +94,7 @@ To get the latest version of the driver, add the following to your POM file:
9494
<dependency>
9595
<groupId>com.microsoft.sqlserver</groupId>
9696
<artifactId>mssql-jdbc</artifactId>
97-
<version>13.1.1.jre11-preview</version>
97+
<version>13.2.0.jre11</version>
9898
</dependency>
9999
```
100100

@@ -129,7 +129,7 @@ Projects that require either of the two features need to explicitly declare the
129129
<dependency>
130130
<groupId>com.microsoft.sqlserver</groupId>
131131
<artifactId>mssql-jdbc</artifactId>
132-
<version>13.1.1.jre11-preview</version>
132+
<version>13.2.0.jre11</version>
133133
<scope>compile</scope>
134134
</dependency>
135135

@@ -147,7 +147,7 @@ Projects that require either of the two features need to explicitly declare the
147147
<dependency>
148148
<groupId>com.microsoft.sqlserver</groupId>
149149
<artifactId>mssql-jdbc</artifactId>
150-
<version>13.1.1.jre11-preview</version>
150+
<version>13.2.0.jre11</version>
151151
<scope>compile</scope>
152152
</dependency>
153153

@@ -174,7 +174,7 @@ When setting 'useFmtOnly' property to 'true' for establishing a connection or cr
174174
<dependency>
175175
<groupId>com.microsoft.sqlserver</groupId>
176176
<artifactId>mssql-jdbc</artifactId>
177-
<version>13.1.1.jre11-preview</version>
177+
<version>13.2.0.jre11</version>
178178
</dependency>
179179

180180
<dependency>

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
apply plugin: 'java'
1313

14-
version = '13.1.1'
15-
def releaseExt = '-preview'
14+
version = '13.2.0'
15+
def releaseExt = ''
1616
def jreVersion = ""
1717
def testOutputDir = file("build/classes/java/test")
1818
def archivesBaseName = 'mssql-jdbc'

mssql-jdbc_auth_LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MICROSOFT SOFTWARE LICENSE TERMS
2-
MICROSOFT JDBC DRIVER 13.1.1 FOR SQL SERVER
2+
MICROSOFT JDBC DRIVER 13.2.0 FOR SQL SERVER
33

44
These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS.
55

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.microsoft.sqlserver</groupId>
77
<artifactId>mssql-jdbc</artifactId>
8-
<version>13.1.1</version>
8+
<version>13.2.0</version>
99
<packaging>jar</packaging>
1010
<name>Microsoft JDBC Driver for SQL Server</name>
1111
<description>
@@ -53,7 +53,7 @@
5353
Default testing enabled with SQL Server 2019 (SQLv15) -->
5454
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest,JSONTest</excludedGroups>
5555
<!-- Use -preview for preview release, leave empty for official release. -->
56-
<releaseExt>-preview</releaseExt>
56+
<releaseExt></releaseExt>
5757
<!-- Driver Dependencies -->
5858
<org.osgi.core.version>6.0.0</org.osgi.core.version>
5959
<azure-security-keyvault-keys.version>4.9.2</azure-security-keyvault-keys.version>
@@ -151,6 +151,7 @@
151151
<groupId>net.bytebuddy</groupId>
152152
<artifactId>byte-buddy</artifactId>
153153
<version>1.15.11</version>
154+
<scope>test</scope>
154155
</dependency>
155156
<dependency>
156157
<groupId>net.bytebuddy</groupId>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
final class SQLJdbcVersion {
99
static final int MAJOR = 13;
10-
static final int MINOR = 1;
11-
static final int PATCH = 1;
10+
static final int MINOR = 2;
11+
static final int PATCH = 0;
1212
static final int BUILD = 0;
1313
/*
1414
* Used to load mssql-jdbc_auth DLL.
1515
* 1. Set to "-preview" for preview release.
1616
* 2. Set to "" (empty String) for official release.
1717
*/
18-
static final String RELEASE_EXT = "-preview";
18+
static final String RELEASE_EXT = "";
1919

2020
private SQLJdbcVersion() {
2121
throw new UnsupportedOperationException(SQLServerException.getErrString("R_notSupported"));

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import java.math.BigDecimal;
99
import java.math.RoundingMode;
10-
import java.nio.charset.Charset;
1110
import java.sql.Types;
1211
import java.text.DecimalFormat;
1312
import java.text.MessageFormat;
@@ -35,7 +34,6 @@ class SQLServerBulkBatchInsertRecord extends SQLServerBulkRecord {
3534
private int batchParamIndex = -1;
3635
private List<String> columnList;
3736
private List<String> valueList;
38-
private Charset charset;
3937

4038
/*
4139
* Class name for logging.
@@ -46,10 +44,10 @@ class SQLServerBulkBatchInsertRecord extends SQLServerBulkRecord {
4644
* Constructs a SQLServerBulkBatchInsertRecord with the batch parameter, column list, value list, and encoding
4745
*/
4846
SQLServerBulkBatchInsertRecord(ArrayList<Parameter[]> batchParam, ArrayList<String> columnList,
49-
ArrayList<String> valueList, Charset charset, boolean columnNameCaseSensitive) throws SQLServerException {
47+
ArrayList<String> valueList, String encoding, boolean columnNameCaseSensitive) throws SQLServerException {
5048
initLoggerResources();
5149
if (loggerExternal.isLoggable(java.util.logging.Level.FINER)) {
52-
loggerExternal.entering(loggerPackageName, loggerClassName, new Object[] {batchParam, charset.name()});
50+
loggerExternal.entering(loggerPackageName, loggerClassName, new Object[] {batchParam, encoding});
5351
}
5452

5553
if (null == batchParam) {
@@ -64,7 +62,6 @@ class SQLServerBulkBatchInsertRecord extends SQLServerBulkRecord {
6462
this.columnList = columnList;
6563
this.valueList = valueList;
6664
this.columnNameCaseSensitive = columnNameCaseSensitive;
67-
this.charset = charset;
6865
columnMetadata = new HashMap<>();
6966

7067
loggerExternal.exiting(loggerPackageName, loggerClassName);
@@ -189,18 +186,7 @@ else if (dateTimeFormatter != null)
189186
case Types.LONGVARCHAR:
190187
case Types.NCHAR:
191188
case Types.NVARCHAR:
192-
case Types.LONGNVARCHAR: {
193-
/*
194-
* If string data comes in as a byte array through setString (and sendStringParametersAsUnicode = false)
195-
* through Bulk Copy for Batch Insert API, convert the byte array to a string.
196-
* If the data is already a string, return it as is.
197-
*/
198-
if (data instanceof byte[]) {
199-
return new String((byte[]) data, charset);
200-
}
201-
return data;
202-
}
203-
189+
case Types.LONGNVARCHAR:
204190
case Types.DATE:
205191
case Types.CLOB:
206192
default: {

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,20 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
788788
return false;
789789
}
790790

791+
/**
792+
* Override TDS token processing behavior for PreparedStatement.
793+
* For regular Statement, the execute API for INSERT requires reading an additional explicit
794+
* TDS_DONE token that contains the actual update count returned by the server.
795+
* PreparedStatement does not require this additional token processing, unless
796+
* generated keys were requested (which requires processing additional TDS tokens).
797+
*/
798+
@Override
799+
protected boolean hasUpdateCountTDSTokenForInsertCmd() {
800+
// When generated keys are requested, we need to process additional TDS tokens
801+
// to properly locate the ResultSet containing the generated keys
802+
return bRequestedGeneratedKeys;
803+
}
804+
791805
/**
792806
* Sends the statement parameters by RPC.
793807
*/
@@ -2218,8 +2232,7 @@ public int[] executeBatch() throws SQLServerException, BatchUpdateException, SQL
22182232
}
22192233

22202234
SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(
2221-
batchParamValues, bcOperationColumnList, bcOperationValueList,
2222-
connection.getDatabaseCollation().getCharset(), isDBColationCaseSensitive());
2235+
batchParamValues, bcOperationColumnList, bcOperationValueList, null, isDBColationCaseSensitive());
22232236

22242237
for (int i = 1; i <= rs.getColumnCount(); i++) {
22252238
Column c = rs.getColumn(i);
@@ -2427,8 +2440,7 @@ public long[] executeLargeBatch() throws SQLServerException, BatchUpdateExceptio
24272440
}
24282441

24292442
SQLServerBulkBatchInsertRecord batchRecord = new SQLServerBulkBatchInsertRecord(
2430-
batchParamValues, bcOperationColumnList, bcOperationValueList,
2431-
connection.getDatabaseCollation().getCharset(), isDBColationCaseSensitive());
2443+
batchParamValues, bcOperationColumnList, bcOperationValueList, null, isDBColationCaseSensitive());
24322444

24332445
for (int i = 1; i <= rs.getColumnCount(); i++) {
24342446
Column c = rs.getColumn(i);

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,8 +1601,8 @@ boolean onDone(TDSReader tdsReader) throws SQLServerException {
16011601
if (null != procedureName)
16021602
return false;
16031603

1604-
// For Insert, we must fetch additional TDS_DONE token that comes with the actual update count
1605-
if ((StreamDone.CMD_INSERT == doneToken.getCurCmd()) && (-1 != doneToken.getUpdateCount())
1604+
// For Insert operations, check if additional TDS_DONE token processing is required.
1605+
if (hasUpdateCountTDSTokenForInsertCmd() && (StreamDone.CMD_INSERT == doneToken.getCurCmd()) && (-1 != doneToken.getUpdateCount())
16061606
&& EXECUTE == executeMethod) {
16071607
return true;
16081608
}
@@ -1845,6 +1845,19 @@ boolean consumeExecOutParam(TDSReader tdsReader) throws SQLServerException {
18451845
return false;
18461846
}
18471847

1848+
/**
1849+
* Determines whether to continue processing additional TDS_DONE tokens for INSERT statements.
1850+
* For INSERT operations, regular Statement requires reading an additional TDS_DONE token that contains
1851+
* the actual update count. This method can be overridden by subclasses to customize
1852+
* TDS token processing behavior.
1853+
*
1854+
* @return true to continue processing more tokens to get the actual update count for INSERT operations
1855+
*/
1856+
protected boolean hasUpdateCountTDSTokenForInsertCmd() {
1857+
// For Insert, we must fetch additional TDS_DONE token that comes with the actual update count
1858+
return true;
1859+
}
1860+
18481861
// --------------------------JDBC 2.0-----------------------------
18491862

18501863
@Override

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

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

7+
import java.nio.Buffer;
78
import java.nio.ByteBuffer;
89
import java.nio.ByteOrder;
910
import java.text.MessageFormat;
@@ -56,7 +57,12 @@ static Vector fromBytes(byte[] bytes) {
5657

5758
ByteBuffer buffer = ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN);
5859

59-
buffer.position(getHeaderLength()); // Skip the first 8 bytes (header)
60+
/*
61+
* The cast is required for JDK 8 compatibility.
62+
* JDK 8 calls method Buffer.position(I)LBuffer,
63+
* while in JDK 9+ calls method ByteBuffer.position(I)LByteBuffer
64+
*/
65+
((Buffer) buffer).position(getHeaderLength()); // Skip the first 8 bytes (header)
6066

6167
for (int i = 0; i < objectCount; i++) {
6268
objectArray[i] = buffer.getFloat();

0 commit comments

Comments
 (0)