Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch fails when always encrypted is enabled in connection string and clearParameters was called #1499

Closed
jezbera opened this issue Jan 18, 2021 · 3 comments · Fixed by #1578 or #1593
Projects

Comments

@jezbera
Copy link

jezbera commented Jan 18, 2021

Driver version

9.1.1.jre11-preview (8.4.1.jre11 is affected too)

SQL Server version

Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0 (X64) Mar 18 2018 09:11:49 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 10.0 (Build 18363: ) (Hypervisor)-->

Client Operating System

Windows/Linux

JAVA/JVM version

11.0.6

Table schema

Table will be created by test.
create table TEST2 (KEY1 numeric(19,0) not null, KEY2 numeric(19,0) not null, primary key (KEY1, KEY2))

Problem description

Prepare database with always encrypted feature. Update connection details in ExecuteBatchTest.java and run tests in attached gradle project.

  1. Expected behaviour:
    No column is encrypted, so it does not matter, whether columnEncryptionSetting is enabled or not.
  2. Actual behaviour:
    Only test with connection string containing "columnEncryptionSetting=Enabled" fails.
  3. Error message/stack trace:
    Index 2 out of bounds for length 2 java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2 at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatementBatch(SQLServerPreparedStatement.java:2764) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtBatchExecCmd.doExecute(SQLServerPreparedStatement.java:2675) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7417) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3274) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2076) at ExecuteBatchTest.executeBatch(ExecuteBatchTest.java:83)
  4. Any other details that can be helpful:
    PreparedStatement executed after clearParameters() fails. cryptoMetaBatch list should be cleared in clearParameters().

JDBC trace logs

mssql-jdbc-trace.txt

Reproduction code

mssql-batch-sample-clearparams.zip

@peterbae
Copy link
Contributor

Hi @jezbera, the team will investigate this.

@karinazhou
Copy link
Member

Hi @jezbera ,
Could you please try the attached jar to see if that fixes your issue?

Thanks,
Karina
mssql-jdbc-GH1499.zip

@lilgreenbird lilgreenbird moved this from In progress to Under Peer Review in MSSQL JDBC May 20, 2021
MSSQL JDBC automation moved this from Under Peer Review to Closed Issues May 27, 2021
@karinazhou
Copy link
Member

Hi @jezbera ,
The fix has been merged so the issue is closed now. Please feel free to give it a try.

Thanks,

@lilgreenbird lilgreenbird linked a pull request Jun 3, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Closed Issues
3 participants