aspose file tools*
The moose likes JDBC and the fly likes table list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "table list" Watch "table list" New topic
Author

table list

shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
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

Joined: Feb 06, 2001
Posts: 358
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

Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: table list