code: boolean isPrimaryKey(int col) {
      if (primaryKeys[col] != null) {
        return primaryKeys[col];
      }
  
      try {
        // Convert column index into JDBC column number.
        int colNum = col + 1;
  
        // If the table name can't be determined exit quickly.
        // this doesn't always work, since some JDBC drivers (e.g.,
        // Oracle's) return a blank string from getTableName.
        String table = rsMeta.getTableName(colNum);
        if (table == null || table.length() == 0) {
          return primaryKeys[col] = false;
        }
  
        // If the column name can't be determined exit quickly.
        String column = rsMeta.getColumnName(colNum);
        if (column == null || column.length() == 0) {
          return primaryKeys[col] = false;
        }
  
        // Retrieve the catalog and schema name for this connection.
        // Either or both may be null.
        final DatabaseMetaData dbMeta =
            sqlLine.getDatabaseConnection().meta;
        String catalog = dbMeta.getConnection().getCatalog();
        String schema = rsMeta.getSchemaName(colNum);
  
        // Get the (possibly cached) set of primary key columns
        // for the table containing this column.
        Set<String> tablePrimaryKeys =
            getTablePrimaryKeys(catalog, schema, table);
  
        // Determine if this column is a primary key and cache the result.
        return primaryKeys[col] = tablePrimaryKeys != null
            && tablePrimaryKeys.contains(column);
  
      } catch (SQLException e) {
        // Ignore the exception and assume that this column
        // isn't a primary key for display purposes.
        return primaryKeys[col] = false;
      }
    }
docs: Return whether the specified column (0-based index) is
  a primary key. Since this method depends on whether
  the JDBC driver property implements
  {@link java.sql.ResultSetMetaData#getTableName} (many do not), it
  is not reliable for all databases.