-1

Currently I am trying to get the primaryKey from cassandra using JDBC API where I am using Apache Simba Driver . We are trying extracting the Primary Key Name but currently it is returning the value as null

try (ResultSet pk = metaData.getPrimaryKeys(catalog,schema,TableName)) {
    if (pk.next()) {
        String primaryKeyName;
        do {
            System.out.println(pk.getString("COLUMN_NAME"));
            primaryKeyName = pk.getString("PK_NAME");
            System.out.println(primaryKeyName);
        while (pk.next());
Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
  • Have you considered that maybe the PK doesn't have a name? Otherwise, you'll need to report a bug to the developer of the JDBC driver. – Mark Rotteveel Feb 13 '23 at 15:47

1 Answers1

1

The Cassandra JDBC driver from Magnitude (formerly Simba) is close-sourced so it is difficult to know whether this is expected behaviour in the way that the driver exposes the metadata for CQL tables or whether it is a bug.

As a workaround, you will need to source the CQL schema to get the details of the primary key.

If you don't have a strict requirement to use the JDBC driver, you should consider using native CQL drivers like the Cassandra Java driver so you get full CQL access.

Otherwise if you have a support account, get in contact with Magnitude for assistance. Cheers!

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23