File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Accessing table names in MSAccess Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Accessing table names in MSAccess" Watch "Accessing table names in MSAccess" New topic

Accessing table names in MSAccess

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I want to retrieve the names of the available tables in MSAccess.
I know how to do this in SQL Server & Oracle .
Can any one please tell me the equivalent command in MSAccess?
Thanks in advance
Amit Manurkar

Joined: Apr 03, 2003
Posts: 11
Hey did u find any solution for your problem ? If yes can you share it with me ?

Amit Manurkar
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

Check out the DatabaseMetaData class. It should provide you with what you need.

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
As already posted check out the databasemetadata API for more information. You can also search this forum.
The following should give you the table names and number of tables.
DatabaseMetaData myMT = conn.getMetaData(); //Used to retrieve information about the database
String[] myTables = {"TABLE"};
ResultSet tables = myMT.getTables(null,
null, "%", myTables);
String tableName = null;
int tableCnt = 0;
while (
tableName = tables.getString("TABLE_NAME");
System.out.println("Table " + tableCnt + ": " + tableName);
System.out.println("Number of tables is : " + tableCnt);

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: Accessing table names in MSAccess
It's not a secret anymore!