wood burning stoves 2.0*
The moose likes General Computing and the fly likes retrieve all the tables from a database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "retrieve all the tables from a database" Watch "retrieve all the tables from a database" New topic
Author

retrieve all the tables from a database

sunita shaw
Ranch Hand

Joined: Apr 06, 2003
Posts: 45
can anyone tell me how to retrieve all the table names from a database in microsoft access . dont tell me select * from table name coz this is just to retrieve the fields of a particular table .
Nilesh Pereira
Ranch Hand

Joined: Apr 14, 2003
Posts: 53
No I'm not going to tell you to select * from table
You need to get the DatabaseMetaData from the database by calling getMetaData() in Connection. Then all you need to do is call getTables(...) in DatabaseMetaData to get the list of tables.
sunita shaw
Ranch Hand

Joined: Apr 06, 2003
Posts: 45
hi! nilesh
thanx for the help but i still havent got it ..can u let me know exactally how do do it.do u have some coding or something.hope u got my problem well.
i.e i want a query in Ms Access 2000 for retrieving the names of the table not a query that will run in SQL server only.
please reply back soon.
Nilesh Pereira
Ranch Hand

Joined: Apr 14, 2003
Posts: 53
Hi Sunita
You can refer DatabaseMetaData for more information.
The code should look something like this:

[ April 21, 2003: Message edited by: Nilesh Pereira ]
Bheemeswara Rao Amruthavakkula
Greenhorn

Joined: Apr 21, 2003
Posts: 2
Hi
Neelesh code works fine but it will return system tables and views also in addition to the table names. replace the following line in the Neelesh code to get only the table names
ResultSet rs = dmd.getTables(null, null, null, new String[]{"TABLE"});
 
Consider Paul's rocket mass heater.
 
subject: retrieve all the tables from a database
 
Similar Threads
Hibernate - How to retrieve data from the database
limitation of retrieving the records from the database
What is Caching ?
Query to retrieve 'COLUMN' names in a table
retrive table name in jsp