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

[JDBC] Execute Stored Procedure with arguments gives error when called stored procedure resides in another DB in same SQL instance #1882

Open
arpanpatel11 opened this issue Jul 29, 2022 · 3 comments
Projects

Comments

@arpanpatel11
Copy link

Driver version

com.microsoft.sqlserver:mssql-jdbc:9.2.1.jre8

SQL Server version

Microsoft SQL Server 2019

Client Operating System

Window

JAVA/JVM version

version "11.0.3"

Table schema

Executing stored procedures ("db2.dbo.testSP");

Problem description

connection string - jdbc:sqlserver://dbserver;databaseName=db1
Connect to the database db1 using the JDBC driver.
Stored Procedure of another database (db2) having arguments (Present in same SQL instance).
When we trying to executed stored procedure other database using name parameters it throws an error "The database name component of the object qualifier must be the name of the current database."
The error throws from method setString(String parameterName, String value) when it try to find column index from parameter name.

findColumn method try to execute stored procedure "exec sp_sproc_columns" at that time it throws the error.

Expected behavior

We would expect the stored procedure successfully execute from other database present in same sql instance.

Actual behavior

it throws the error.

Error message/stack trace

com.microsoft.sqlserver.jdbc.SQLServerException: com.microsoft.sqlserver.jdbc.SQLServerException: The database name component of the object qualifier must be the name of the current database.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.findColumn(SQLServerCallableStatement.java:1340)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.setString(SQLServerCallableStatement.java:1937)

Any other details that can be helpful

Add any other context about the problem here.

JDBC trace logs

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

@tkyc
Copy link
Member

tkyc commented Jul 29, 2022

I'll try and reproduce this on my end and investigate. In the mean time, if possible could you provide a repro app of the issue to expedite the investigation? Thanks.

@arpanpatel11
Copy link
Author

attaching stored procedure and test java program to reproduce issue.

mssql_jdbc_sp_issue.zip

@lilgreenbird lilgreenbird added this to Under Investigation in MSSQL JDBC via automation Aug 4, 2022
@lilgreenbird lilgreenbird moved this from Under Investigation to In progress in MSSQL JDBC Aug 4, 2022
@lilgreenbird lilgreenbird moved this from In progress to Under Investigation in MSSQL JDBC Aug 4, 2022
@lilgreenbird
Copy link
Member

hi @arpanpatel11

Thanks for the repro we will take a look. We are currently very busy finalizing our GA release we will look into this again as soon as we can. Thanks!

@tkyc tkyc moved this from Under Investigation to Backlog in MSSQL JDBC Nov 10, 2022
@Jeffery-Wasty Jeffery-Wasty moved this from Backlog to In progress in MSSQL JDBC Oct 17, 2023
@Jeffery-Wasty Jeffery-Wasty moved this from In progress to Backlog in MSSQL JDBC Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
MSSQL JDBC
  
Backlog
Development

No branches or pull requests

3 participants