![]() |
The Java Developers Almanac 1.4 |
|
e247. 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) {
}
e246. Deleting a Database Table e248. Creating a MySQL Table to Store Java Types e249. Creating an Oracle Table to Store Java Types e250. Creating a SQLServer Table to Store Java Types © 2002 Addison-Wesley. |