Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

DatabaseMetaData API

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to display all the meta data information like,

1.List Of Tables
2.List Of Columns for in a table
3.Constraints on columns and tables
4.Primary Keys
5.foreign Keys...

i tried in the followimg way....

DatabaseMetaData metadata=con.getMetaData();
ResultSet rs=metadata.getTables(null,"Schema","*",null);

from this point i could not proceed further...

Please let me know code examples for this meta data or let me know how to proceed further...

suggesting any specific books with code examples related to meta data wud be helpful for me..


Thanks In Advance..
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can get the table names as follows:

DatabaseMetaData dbmd = dbConn.getMetaData();
ResultSet rsTables = dbmd.getTables(server.getInitialCatalog(), null, null, null);
String tableType = null;

while (rsTables.next()) {
tableType = rsTables.getString("TABLE_TYPE");
if (tableType.equals("TABLE")) {
tableListModel.add(tableCount, rsTables.getString("TABLE_NAME"));
tableCount++;
}
}

This link has a pretty good explanation of it.
http://members.aol.com/kgb1001001/Articles/JDBCMetadata/JDBC_Metadata.htm

Eric
 
VenuGopal Reddy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Very Much Eric...Will go thru the link you have suggested...
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic