Skip to content

Wrong handles used in SQLServerPreparedStatement after reconnect of connection #2352

@HeinzHuberRsg

Description

@HeinzHuberRsg

Driver version

10.2.3 - 12.6.0

SQL Server version

2019

Client Operating System

Windows, Linux

JAVA/JVM version

1.8.0, 17

Table schema

Nothing special

Problem description

After a reconnect of an SQLServerConnection, various errors CAN happen when using previously prepared statements. These errors all come from executing or trying to execute a wrong statement on the database side.

Expected behavior

Previously prepared statements can still be used (reliably) after an automatic reconnect.

Actual behavior

Previously prepared statements MAY fail (details see below).

Error message/stack trace

n/a since it is not a single point of failure

Any other details that can be helpful

Steps to reproduce the problem:

  1. configure connectRetryCount > 0
  2. connect to the database
  3. prepare 2 statements a+b with different number of parameters
  4. execute them several times => a should have handle 1, b should have handle 2
  5. kill the tcp connection to the database
  6. execute statement b => an automatic reconnect should be triggered, statement works and gets a new handle 1 after handling "handle 2 not found" internally
  7. execute statement a => should try to use handle 1 and fail

JDBC trace logs

Provided in support case 2402210030004759
The case also contains an app to reproduce the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed Issues

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions