microsoft / mssql-jdbc

The Microsoft JDBC Driver for SQL Server is a Type 4 JDBC driver that provides database connectivity with SQL Server through the standard JDBC application program interfaces (APIs).
MIT License
1.06k stars 424 forks source link

PreparedStatement.getParameterMetaData has problems with encyrpted connections #493

Closed gs-rezaem closed 5 years ago

gs-rezaem commented 7 years ago

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();
AfsanehR-zz commented 7 years ago

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!

cheenamalhotra commented 5 years ago

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.

peterbae commented 5 years ago

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