Listing All Table Names in a Database

try { // Gets the database metadata DatabaseMetaData dbmd = connection.getMetaData(); // Specify the type of object; in this case we want tables String[] types = {"TABLE"}; ResultSet resultSet = dbmd.getTables(null, null, "%", types); // Get the table names while (resultSet.next()) { // Get the table name String tableName = resultSet.getString(3); // Get the table's catalog and schema names (if any) String tableCatalog = resultSet.getString(1); String tableSchema = resultSet.getString(2); } } catch (SQLException e) { }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.