2. // return the primary key of a given table
// as an ArrayList<string> with the primary key columns in proper // order
ArrayList<string> getPrimaryKey(String tableName) OR PREFERABLY:
write a method to return all the primary keys of all the tables at once.
3. // for a given table, return a list of 4-tuples which are // the relational constraints from foreign tables into this // table's primary keys. Each 4-tuple looks like this: // [PKTABLE_NAME, PKCOLUMN_NAME, FKTABLE_NAME, FKCOLUMN_NAME]
public ArrayList<arraylist<string>> getTableConstraints(String tableName)
write a method to return all the relational constraints of all the tables at once.
4.// return a list of all the columns in the database as // a list of triples. Each triple looks like this: // [TABLE_NAME, COLUMN_NAME, DATA_TYPE]
For getting the foreign key relationships you'll have to enable the read permission to system table vi access (refer to screenshots).
Here are the Function Prototypes that are called :
1. private ArrayList<string> gettablenames(Connection con) throws SQLException
2. private ArrayList<string> getprimarykey(Connection con,String tablename) throws SQLException
3. ArrayList<arraylist><string>> getforeignKeys(Connection con,String tablename) throws SQLException
4. ArrayList<arraylist><string>> reallyGetColumns(Connection con) throws SQLException
Test The application by double clicking the jar. I am also attaching the database that i used to test it.