CData JDBC Driver for Magento 2019 - Online Help
Questions / Feedback?

Primary Keys

CData JDBC Driver for Magento 2019 - Build 19.0.7354

You can use the getPrimaryKeys method to return information about the primary keys for Magento tables. You can restrict the results by the table name.

The following code example outputs the column or columns composing the primary key for the Products table:

String connectionString = "jdbc:magento:Schema=magento2;User=admin;Password=admin;Url=https://mymagentohost/magento2";

Connection conn = DriverManager.getConnection(connectionString);
ResultSet rs = conn.getMetaData().getPrimaryKeys(null,null,"Products");
while(rs.next()){
  System.out.println(rs.getString("COLUMN_NAME"));
}

The getPrimaryKeys method returns the following columns:

Column NameData TypeDescription
TABLE_CATStringThe table catalog
TABLE_SCHEMStringThe table schema.
TABLE_NAMEStringThe table name.
COLUMN_NAMEStringThe column name.
KEY_SEQshortThe sequence number, or column index starting from 1, within the foreign key.
PK_NAMEStringThe primary key name.

 
 
Copyright (c) 2020 CData Software, Inc. - All rights reserved.
Build 19.0.7354.0