• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing table names in MSAccess

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
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
Surya
 
Amit Manurkar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey did u find any solution for your problem ? If yes can you share it with me ?
 
Joel McNary
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the DatabaseMetaData class. It should provide you with what you need.
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 (tables.next())
{
tableName = tables.getString("TABLE_NAME");
++tableCnt;
System.out.println("Table " + tableCnt + ": " + tableName);
}
System.out.println("Number of tables is : " + tableCnt);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic