• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listing out tables in a database

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I'm connecting to a database and want to display all the available tables under that database. How can I do it?

I checked the whole java.sql api..but didn't find anything which actually displays the tables under a database..

Plz help
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All the metadata functionality of JDBC is supplied by jav.sql.DatabaseMetaData. If there's nothing in there to do what you want, you'll have to resort to the verdor-specific queries for doing this ("show tables" in mysql, "select * from user_tables" in Oracle, "select * from sysobjects where xtype ='U'" in MSSQL etc.)

[ June 11, 2004: Message edited by: Paul Sturrock ]
[ June 11, 2004: Message edited by: Paul Sturrock ]
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly.Will give you all tables and views in a given schema. See the javadoc for further information on the metadata API. For a detailed discussion, the standard recommendation is the excellent The JDBC API Tutorial and Reference (reviewed in the Bunkhouse; I should add that as one of the tech reviewers on this book I'm not unprejudiced).

- Peter
[ June 11, 2004: Message edited by: Peter den Haan ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic