tags:

views:

64

answers:

2

Hi

I am starter and i want to know how to find a specific column is a FOREIGN KEY column in the database.

what i am doing is.....

I am getting a connection object from a specific data source. Using this connection object i am trying to get all the metadata of that specific datasource using DatabaseMetadata. I worked on getColumns, getPrimarykeys etc. But now i know what the tablename is what the column name is in that specific table. I want to know is that column a FORIGEN KEY column are not.

For example if i know column name i can know if that column is a PRIMARY KEY column are not in the same way i need it for a FOREGIN KEY.

Can some one help me in this

Thanks Kumar

+3  A: 

have a look at the getExportedKeys and getImportedKeys methods. They should tell you what you want to know in a round about way...

pstanton
A: 

Take a look at SchemaCrawler (free and open source), which is an API designed to obtain database metadata easily, as plain-old Java objects.

Sualeh Fatehi