You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Microsoft SQL Server 2017 (RTM-CU9-GDR) (KB4293805) - 14.0.3035.2 (X64) Jul 6 2018 18:24:36 Copyright (C) 2017 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)
Client Operating System
Windows 10
JAVA/JVM version
JDK 11
Table schema
createdatabasetest_sp
go
use test_sp
go
create proc test @id int,@str varchar(max) asselect @id,@str
go
create login reader with password='password_reader',default_database=test_sp
createuserreader for login reader
alter role db_datareader add member reader
go
create login executor with password='password_executor',default_database=test_sp
createuserexecutor for login executor
alter role db_datareader add member executor
grant execute on test to executor
go
Problem description
When calling a stored procedure with at least two parameters from JDBC under insufficient rights, the error message is misleading.
Expected behaviour: SQLServerException with message The EXECUTE permission was denied on the object 'test'
Actual behaviour: SQLServerException with message The value is not set for the parameter number 2.
Error message/stack trace:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The value is not set for the parameter number 2.
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:226)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildParamTypeDefinitions(SQLServerPreparedStatement.java:416)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildPreparedStrings(SQLServerPreparedStatement.java:369)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:540)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:508)
at com.microsoft//com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:243)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:218)
at com.microsoft//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:493)
Driver version
7.2.2.jre11 (also tested with 7.0.0.jre10)
SQL Server version
Microsoft SQL Server 2017 (RTM-CU9-GDR) (KB4293805) - 14.0.3035.2 (X64) Jul 6 2018 18:24:36 Copyright (C) 2017 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Standard 10.0 <X64> (Build 17763: ) (Hypervisor)Client Operating System
Windows 10
JAVA/JVM version
JDK 11
Table schema
Problem description
When calling a stored procedure with at least two parameters from JDBC under insufficient rights, the error message is misleading.
SQLServerExceptionwith messageThe EXECUTE permission was denied on the object 'test'SQLServerExceptionwith messageThe value is not set for the parameter number 2.Similar issue: Misleading SQLServerException: Parameter was not defined for stored procedure #608.
JDBC trace logs
n/a
Reproduction code
I created a small github repo to reproduce the issue: https://github.com/cnsgithub/sqljdbc. Just clone the repo, setup the DB schema and execute the unit test using plain JDBC.