Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.

Have Programming Question? Ask it here!
 
 
 


Clark
Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.
1 Answer(s)      3 years and 10 months ago
Posted in : JDBC


Is there a way to find the primary key(s) for an Access Database table? Sun's JDBC-ODBC driver does not implement the getPrimaryKeys() method for the DatabaseMetaData Objects.


Advertisement
View Answers

November 15, 2010 at 4:26 PM


Hi friends,

// Use meta.getIndexInfo() will //get you the PK index. Once // you know the index, retrieve its column name

DatabaseMetaData meta = con.getMetaData();

String key_colname = null;

// get the primary key information
rset = meta.getIndexInfo(null,null, table_name, true,true);
while( rset.next())
   {
String idx = rset.getString(6);
 if( idx != null)
 {
//Note: index "PrimaryKey" is Access DB specific
//      other db server has diff. index syntax.
if( idx.equalsIgnoreCase("PrimaryKey"))
{
  key_colname = rset.getString(9);
  setPrimaryKey( key_colname );
}

} .

Thanks.



Related Tutorials/Questions & Answers:
 

 

 

DMCA.com