Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get table names from a database in access

 
Aditya Torvi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code works with Oracle, Sybase, MySQL.

public void listTables()
{
Connection connection = getConnection();
String catalogName, /* this can be null for all catalogs */
schemaName, /* this can be null for all schemas */
tableType = "TABLE"; /* this can be null for "any" type */


if ((connection != null) && (tableType != null)) {
DatabaseMetaData dmd = connection.getMetaData();
ResultSet rs;


rs = dmd.getTables(catalogName, schemaName, null, new String[]{tableType });

while (rs.next()) {
System.out.println("Table name = " +
rs.getString("TABLE_NAME"));
}
rs.close();
}
}

But gives this exception for Access-
[Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented

Any suggestions?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your driver doesn't implement the getTables method. Change your driver. From the java.sql.DatabaseMetaData JavaDoc:


Different relational DBMSs often support different features, implement features in different ways, and use different data types
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!