Skip to content

Concatenated select SQL Statement returns null in JDBC Driver 12.10 #2722

@psmacalp

Description

@psmacalp

Driver version

JDBC Driver 12.10

SQL Server version

Provide the output of executing SELECT @@VERSION on your target SQL Server.

Microsoft SQL Server 2022 (RTM-GDR) (KB5058712) - 16.0.1140.6 (X64)   Jun 19 2025 11:40:25   Copyright (C) 2022 Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Enterprise 10.0 <X64> (Build 26100: ) (Hypervisor)

Client Operating System

Windows 11 Enterprise 24H2

JAVA/JVM version

IBM Java 8 SDK (running on IBM WebSphere Application Server traditional)

Table schema

USE [OS1]
GO
/****** Object:  Table [dbo].[testTable]    Script Date: 7/24/2025 10:36:36 AM ******/
CREATE TABLE [dbo].[testTable](
	[c1] [int] NULL,
	[c2] [smallint] NULL
) ON [PRIMARY]

Problem description

Starting with JDBC driver 12.10, the following resultset will be null and seems to ignore the select statement at the end. This is a regression from previous JDBC driver versions before 12.10. It is causing an issue in our product that has been deployed to many of our customers and prevents them from upgrading to JDBC driver 12.10.

PreparedStatement ps= conn.prepareStatement("delete from TestTable; INSERT INTO TestTable (c1,c2) VALUES (?, ?); select * from TestTable ");
ResultSet resultset = ps.execute();

We discovered the workaround here is to not append the select statement at the end of the SQL query. However, when we do this we cannot include the select SQL Statement in a batch, which means that there is a performance hit due to this regression. So, while we do have a workaround, we would very much prefer a fix to restore the previous behavior to prevent a performance regression from this workaround.

Expected behavior

Expected behavior is that the concatenated select statement returns a value and does not return null.

Actual behavior

The actual behavior is that the concatenated select statement is returning null for the ResultSet.

Error message/stack trace

There is no error message, just a change in behavior causing the returned ResultSet to be null when it should not be null.

Any other details that can be helpful

We have had multiple customers in the field report this issue when using Microsoft SQL JDBC Driver 12.10 with our product. We reproduced the issue internally and independently of our product. We have simplified the reproduction steps in a way that does not require our product.

We opened a support case with Microsoft (Support Case Request ID 2507160040014065). The support person indicated he had seen others report this issue and requested that we open this Git issue. The support person recommended that we should not batch our SQL statements when doing the workaround. Our testing shows that we can batch all of our insert and update statements, but cannot batch our select statements. This means we have a performance hit as compared to pre-12.10 behavior, but is less than the performance hit of having no batching at all.

JDBC trace logs

Provide the JDBC driver trace logs. Instructions can be found here: https://docs.microsoft.com/sql/connect/jdbc/tracing-driver-operation

SQLServer.log

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions