Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-9606

JDBC getPrimaryKeys() returns wrong value for COLUMN_NAME

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.6
    • 2.8
    • jdbc
    • None

    Description

      JDBC getPrimaryKeys() method returns _KEY as column name rather than actual column name. This breaks apps that expect a valid column name as the primary key.

      Trivially reproducible:

        public static void main(String[] args) throws Exception {
          // Register JDBC driver.
          Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
      
          // Open JDBC connection.
          try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/")) {
            // Create database tables.
            try (Statement stmt = conn.createStatement()) {
              stmt.executeUpdate("CREATE TABLE TESTER (" + " ID LONG PRIMARY KEY, NAME VARCHAR) " + " WITH \"template=replicated\"");
            }
      
            // Get database metadata
            DatabaseMetaData md = conn.getMetaData();
      
            // Get primary keys
            ResultSet rs = md.getPrimaryKeys(conn.getCatalog(), "", "TESTER");
      
            //
            while (rs.next()) {
              // Column 4 is COLUMN_NAME
              System.out.println("Primary key column is " + rs.getString(4));
            }
          }
        }
      

      Expected output is:

      Primary key column is ID
      

      Actual output is:

      Primary key column is _KEY
      

      Attachments

        Issue Links

          Activity

            People

              pkouznet Pavel Kuznetsov
              metadaddy Pat Patterson
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: