This example shows how to return a list of tables.
// Connect to iSeries server. Connection c = DriverManager.getConnection("jdbc:db2:mySystem"); // Get the database meta data from the connection. DatabaseMetaData dbMeta = c.getMetaData(); // Get a list of tables matching this criteria. String catalog = "myCatalog"; String schema = "mySchema"; String table = "myTable%"; // % indicates search pattern String types[] = {"TABLE", "VIEW", "SYSTEM TABLE"}: ResultSet rs = dbMeta.getTables(catalog, schema, table, types); // ... iterate through the ResultSet to get the values. // Close the connection. c.close():
For more information, see DatabaseMetaData interface for IBM® Developer Kit for Java™.