• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

table list

 
shankar vembu
Ranch Hand
Posts: 309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i want to print the list of all tables in a database. i went thru the API DatabaseMetaData.getTables() but am not able to use it bcoz i didnt quite clearly understand the parameters it takes.
could anyone gimme a detailed explanation for this, if possible with an example for a database vendor like sybase,db2 or oracle.
thanx in advance,
shanks.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you were in the right direction. Just check the API for the specific details http://java.sun.com/j2se/1.3/docs/api/index.html
public ResultSet getTables(String catalog,
String schemaPattern,
String tableNamePattern,
String[] types)
throws SQLException
Gets a description of tables available in a catalog.
Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
Each table description has the following columns:
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
TABLE_TYPE String => table type. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
REMARKS String => explanatory comment on the table
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the getTables method of databaseMetaData interface the four parameter requires an array of table types. Typical types are "TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
Anyways you can check the following code.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic