microsoft/mssql-jdbc

PreparedStatement.getParameterMetaData has problems with encyrpted connections

gs-rezaem opened this issue · 3 comments

Driver version or jar name

HEAD

SQL Server version

2016

Client operating system

Win 7

Java/JVM version

1.8.0_xxx

Table schema

from the driver test cases. see code below.

Problem description

calling PreparedStatment.getParameterMetaData throws this exception:
com.microsoft.sqlserver.jdbc.SQLServerException: Operand type clash: void type is incompatible with date encrypted with (encryption_type = 'RANDOMIZED', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'JDBC_CEK', column_encryption_key_database_name = 'XYZ')

Expected behavior and actual behavior

no exception should be thrown

Repro code

add one line to the existing jdbc test cases. In AESetup.java, add the last line here:

    protected static void populateDateNormalCase(LinkedList<Object> dateValues) throws SQLException {
        String sql = "insert into " + dateTable + " values( " + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?," + "?,?,?" + ")";

        pstmt = (SQLServerPreparedStatement) Util.getPreparedStmt(con, sql, stmtColEncSetting);
        ParameterMetaData parameterMetaData = pstmt.getParameterMetaData();

Hi @gs-rezaem. Thanks for filing out this issue. As of now, Microsoft JDBC driver does not support retrieval of parameter metadata for encrypted columns. Please check the documentation here.

We will provide the support in near future. Will update you on this github issue once completed. Thanks!

Related Issue #887
'sp_describe_undeclared_parameters' doesn't support temp tables.

Proposed fix for both issues:
Provide an option to switch to SET FMTONLY to gather Parameter MetaData since 'sp_describe_undeclared_parameters' has known limitations and backward compatibility issues.

Issue is being tracked in #927, closing this issue.