This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes how to display primary keys from metadata Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "how to display primary keys from metadata" Watch "how to display primary keys from metadata" New topic

how to display primary keys from metadata

waleed atef abdel elazyz

Joined: Nov 01, 2004
Posts: 13
Dear all,
I have problem how to display and get primary keys from

databasemetadata .but already used method getprimarykeys()from

databasemetadata but the result dont understand.

I want name acolumn(primary key)from the table

thanks,Best regards
[ December 14, 2004: Message edited by: waleed atef abdel elazyz ]
jeroen riezebeek

Joined: Nov 26, 2002
Posts: 9
to get the primary keys directly from the databasemetadata is not possible.
You can get the primary key with the method getPrimaryKeys(String catalog, String schema, String table).
This method returns a resultset witht primary keys.
Since there isn't a primary key object will the resultset exists of primary key names.
For more information see javadoc about the DatabaseMateData object.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: how to display primary keys from metadata
It's not a secret anymore!