getParameterMetadata fails for statements against temp tables
jkoskela opened this issue · 2 comments
Driver version
7.0.0 Fails
4.0.0 OK
SQL Server version
Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64)
Apr 29 2016 23:23:58
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 (Build 9600: )
Client Operating System
Windows 10
JAVA/JVM version
Oracle JVM 1.8.0_181
Table schema
X INTEGER
Problem description
- Expected behaviour: I should be able to get parameter metadata for inserts into temp table.
- Actual behaviour: Invalid object name '#test_jdbc_insert'
The problem appears to be from the use of sp_describe_undeclared_parameters. The driver appears to be throwing from this exec sp_describe_undeclared_parameters @tsl=N'insert into [tempdb].[#test_insert_jdbc] values(@P0)'
. This is understandable since sp_describe_undeclared_parameters doesn't support temp tables. But does this mean that getParameterMetadata doesn't work for statements against temp tables by design? This scenario works using sqljdbc 4.0.0.
Reproduction code
Connection connect = DriverManager.getConnection(connectMssql);
Statement statement = connect.createStatement();
statement.execute("create table [#test_jdbc_insert] (x int)");
PreparedStatement pstmt = connect.prepareStatement("insert into [#test_jdbc_insert] (x) values(?)");
System.out.println(pstmt.getParameterMetaData());
Hi @jkoskela
Thanks for bringing up the issue. sp_describe_undeclared_parameters
has many other limitations including this one. In order to fix these issues, we will allow users to switch to set fmtOnly, when fetching ParameterMetaData, which will be worked on soon.
We have an open issue #493 that is also related. I will link this issue there so it can be tracked with other limitations.