Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12973

CONNECT Engine table_type=JDBC CATFUNC=TABLES w/Microsoft JDBC driver not working

Details

    Description

      When using CONNECT engine with table_type=JDBC and CATFUNC=TABLES and the official Microsoft JDBC driver (latest v6 for jre 8 environment) the list of tables comes back (there are multiple rows) but all the table names are blank.

      The test case:

      CREATE OR REPLACE TABLE parasql_connect_tables
      ENGINE=CONNECT 
      TABLE_TYPE=JDBC 
      CATFUNC=TABLES  
      CONNECTION='jdbc:sqlserver://parasqleu.database.windows.net:1433;databaseName=ParaSQL;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=15;' 
      OPTION_LIST='USER=parasqleu,PASSWORD=WillProvidePassInPrivateMessage,MEMORY=3,DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver' 
      QUOTED=1  
       
      select * from  parasql_connect_tables
       
      [results below are tab separated, only Table_Type is not blank]
       
      Table_Cat	Table_Schema	Table_Name	Table_Type	Remark
      			                             TABLE	
      			                             TABLE	
      			                             TABLE	
      			                             VIEW	
      			                             VIEW	
      

      And similar for CATFUNC=COLUMNS if I manually specify a valid table on the remote server:

      CREATE OR REPLACE TABLE parasql_connect_columns 
      ENGINE=CONNECT 
      TABLE_TYPE=JDBC 
      CATFUNC=COLUMNS 
      TABNAME='customerNew'  
      CONNECTION='jdbc:sqlserver://parasqleu.database.windows.net:1433;databaseName=ParaSQL;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=15;' 
      OPTION_LIST='USER=parasqleu,PASSWORD=WillProvidePassInPrivateMessage,MEMORY=3' 
      QUOTED=1 
      

      select * from  parasql_connect_columns 
       
      [results below, Data_Type etc are filled in but the first 4 columns are not]
       
      Table_Cat	Table_Schema	Table_Name	Column_Name	Data_Type	Type_Name	Column_Size	Buffer_Length	Decimal_Digits	Radix	Nullable	Remarks
      				4		10	4	0	10	1	
      				12		30	30	0	0	1	
      				91		10	6	0	0	1	
      				93		23	16	3	0	1	
      
      

      The latest Microsoft JDBC driver can be downloaded here:
      https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

      NOTE: To ease testing, I can provide the password for the above Microsoft server in a private message so you don't have to set up an environment to test.

      Thank you.

      Attachments

        Activity

          rdyas Robert Dyas added a comment -

          I've created a simple java command line program that you can compile and test - it produces the CORRECT output, so something must be strange with how CONNECT is doing it.

          import java.sql.*;
          public class ListTables {
            public static void main(String [] args) {
              Connection con = null;
              try {
                con = DriverManager.getConnection("jdbc:sqlserver://parasqltest.database.windows.net:1433;database=test6;user=testuser1@parasqltest;password=AskForPassword;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;");
           
                DatabaseMetaData meta = con.getMetaData();
           
                ResultSet res = meta.getTables(null, null, null,  null);
           
                System.out.println("List of tables: ");
                while (res.next()) {
                   System.out.println(
                      "   "+res.getString("TABLE_CAT")
                     + ", "+res.getString("TABLE_SCHEM")
                     + ", "+res.getString("TABLE_NAME")
                     + ", "+res.getString("TABLE_TYPE")
                     + ", "+res.getString("REMARKS"));
                }
           
                res.close();
           
                con.close();
           
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
          

          complile:
          javac ListTables.java

          run:
          java -cp .:/path/to/sqljdbc42.jar ListTables

          produces out like this (CORRECT):

          List of tables: 
             test6, dbo, rob_test, TABLE, null
             test6, dbo, rob_test_vendor, TABLE, null
             test6, sys, trace_xe_action_map, TABLE, null
             test6, sys, trace_xe_event_map, TABLE, null
             test6, INFORMATION_SCHEMA, CHECK_CONSTRAINTS, VIEW, null
          

          For some reason in CONNECT, the first 3 columns are blank.

          rdyas Robert Dyas added a comment - I've created a simple java command line program that you can compile and test - it produces the CORRECT output, so something must be strange with how CONNECT is doing it. import java.sql.*; public class ListTables { public static void main(String [] args) { Connection con = null ; try { con = DriverManager.getConnection( "jdbc:sqlserver://parasqltest.database.windows.net:1433;database=test6;user=testuser1@parasqltest;password=AskForPassword;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;" );   DatabaseMetaData meta = con.getMetaData();   ResultSet res = meta.getTables( null , null , null , null );   System.out.println( "List of tables: " ); while (res.next()) { System.out.println( " " +res.getString( "TABLE_CAT" ) + ", " +res.getString( "TABLE_SCHEM" ) + ", " +res.getString( "TABLE_NAME" ) + ", " +res.getString( "TABLE_TYPE" ) + ", " +res.getString( "REMARKS" )); }   res.close();   con.close();   } catch (Exception e) { e.printStackTrace(); } } } complile: javac ListTables.java run: java -cp .:/path/to/sqljdbc42.jar ListTables produces out like this (CORRECT): List of tables: test6, dbo, rob_test, TABLE, null test6, dbo, rob_test_vendor, TABLE, null test6, sys, trace_xe_action_map, TABLE, null test6, sys, trace_xe_event_map, TABLE, null test6, INFORMATION_SCHEMA, CHECK_CONSTRAINTS, VIEW, null For some reason in CONNECT, the first 3 columns are blank.
          rdyas Robert Dyas added a comment -

          Olivier,

          Will your fix for table names & column names make it into 10.1.25?

          rdyas Robert Dyas added a comment - Olivier, Will your fix for table names & column names make it into 10.1.25?

          I pushed the fix. Whether or not it is included in the distribution of the next versions does not depend on me.

          bertrandop Olivier Bertrand added a comment - I pushed the fix. Whether or not it is included in the distribution of the next versions does not depend on me.
          rdyas Robert Dyas added a comment -

          I was just wondering since the Status for this one is still showing Open rather than Confirmed, In Progress or Fixed (or whatever the right status is).

          rdyas Robert Dyas added a comment - I was just wondering since the Status for this one is still showing Open rather than Confirmed, In Progress or Fixed (or whatever the right status is).

          I just forgot to close it!

          bertrandop Olivier Bertrand added a comment - I just forgot to close it!
          rdyas Robert Dyas added a comment -

          I just installed 10.1.25 and this fix is NOT included in that release
          We really need this fix.

          Was it not included by accident or on purpose? I noticed the change log for 10.1.25 did not list MDEV-12973 either.

          rdyas Robert Dyas added a comment - I just installed 10.1.25 and this fix is NOT included in that release We really need this fix. Was it not included by accident or on purpose? I noticed the change log for 10.1.25 did not list MDEV-12973 either.

          Surely not on purpose. But I had confirmation that CONNECT changes had not been included in Version 10.1.25... by accident?

          bertrandop Olivier Bertrand added a comment - Surely not on purpose. But I had confirmation that CONNECT changes had not been included in Version 10.1.25... by accident?
          rdyas Robert Dyas added a comment -

          Just saw that this is not listed as fixed in the 10.2.7 Changelog.

          Strange... it looks like other CONNECT changes were included in 10.2.7 but not this one... any idea why not included?

          rdyas Robert Dyas added a comment - Just saw that this is not listed as fixed in the 10.2.7 Changelog. Strange... it looks like other CONNECT changes were included in 10.2.7 but not this one... any idea why not included?

          Sorry for this. Because of a merge mistake this fix didn't end up in 10.2.7, it'll only be in 10.2.8.

          serg Sergei Golubchik added a comment - Sorry for this. Because of a merge mistake this fix didn't end up in 10.2.7, it'll only be in 10.2.8.
          rdyas Robert Dyas added a comment -

          Is this now actually included in 10.1.26 ?
          It is not listed in the change log nor the release notes.

          rdyas Robert Dyas added a comment - Is this now actually included in 10.1.26 ? It is not listed in the change log nor the release notes.
          rdyas Robert Dyas added a comment -

          OK, initial testing of NVARCHAR is working, so I guess the changes were integrated just not listed in the change log. Pretty big change not to list!

          rdyas Robert Dyas added a comment - OK, initial testing of NVARCHAR is working, so I guess the changes were integrated just not listed in the change log. Pretty big change not to list!

          There has been a git problem in the change log that caused it to be lost. However hopefully all the recent fixes should be included.

          bertrandop Olivier Bertrand added a comment - There has been a git problem in the change log that caused it to be lost. However hopefully all the recent fixes should be included.

          People

            bertrandop Olivier Bertrand
            rdyas Robert Dyas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.