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

Wrong parameter count after CallableStatement#setObject(String, Object, int) #1871

Closed
coladict opened this issue Jul 19, 2022 · 1 comment · Fixed by #1898
Closed

Wrong parameter count after CallableStatement#setObject(String, Object, int) #1871

coladict opened this issue Jul 19, 2022 · 1 comment · Fixed by #1898
Projects

Comments

@coladict
Copy link

Driver version

All current, including 11.1.2. Discovered when using 9.2.1

SQL Server version

irrelevant

Client Operating System

Debian 11.4

JAVA/JVM version

11.0.15

Problem description

Calling a method with 10 parameters. Getting this error when setting the 8th.

com.microsoft.sqlserver.jdbc.SQLServerException: The index 11 is out of range.

I've located the problem occurs when a method calls findColumn(parameterName) multiple times.
the problem is inside private int findColumn(String columnName)

map.putIfAbsent(columnName, ai.incrementAndGet());
return map.get(columnName);// attempting to look up the first column will return no access exception

The ai.incrementAndGet() is called even though the parameter is already present.
This is fine if there are no more parameters after it, but there are this time.
suggested correction:

return map.computeIfAbsent(columnName, ignored -> ai.incrementAndGet());
@lilgreenbird lilgreenbird added this to Under Investigation in MSSQL JDBC via automation Jul 19, 2022
@tkyc
Copy link
Member

tkyc commented Jul 19, 2022

Hi @coladict, thanks for bringing this to our attention. Currently we're busy preparing for release, would it be possible for you to open a PR? Or could you provide us a repro that we can use for a test? If not we'll try and address this as soon as we can.

@tkyc tkyc added the Backlog The topic in question has been recognized and added to development backlog label Jul 26, 2022
@lilgreenbird lilgreenbird moved this from Under Investigation to Backlog in MSSQL JDBC Aug 4, 2022
MSSQL JDBC automation moved this from Backlog to Closed Issues Aug 22, 2022
@Jeffery-Wasty Jeffery-Wasty removed the Backlog The topic in question has been recognized and added to development backlog label Aug 22, 2022
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