Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes Finding primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Finding primary key" Watch "Finding primary key" New topic

Finding primary key

Shashikanth Ravulapelli

Joined: May 09, 2001
Posts: 1
Is there any way to find out Primary key from a resultset. I looked in ResultSetMetaData and ResultSet interfaces, and couldn't find any. My problem is to copy a row in one of the table, which has a primary key. During insertion time, you cannot specify a value for Primary key column and i would like to skip the value in the result set which is a value for the primary key.

Yogen Vadnere
Ranch Hand

Joined: Sep 20, 2001
Posts: 58
DatabaseMetaData has two methods
getPrimaryKeys(String catalog, String schema, String table)
Hope this will work for u..

Yogen Vadnere
It is sorta covered in the JavaRanch Style Guide.
subject: Finding primary key
It's not a secret anymore!