package com.geostar.geosmarter;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Test07 {
static void main public (String [] args) {
String = Driver "oracle.jdbc.driver.OracleDriver";
String URL = "JDBC: Oracle: Thin: @ 192.168.30.80: 1521: ORCL";
String username = "Kettle" ;
String password = "123456";
the try {
the Class.forName (Driver);
Connection Connection = the DriverManager.getConnection (URL, username, password);
the DatabaseMetaData Connection.getMetaData The metaData = ();
/ **
* metaData.getTables (Catalog, schemaPattern, tableNamePattern, types)
Cataog directory name
schema schema name pattern (typically a user name, note the capital), null check all, can not be used ""Instead of null
tableName table name (null check all)
table type string array types. null check all, can not be used "" instead of null
* * /
the ResultSet Tables metaData.getTables = (null, username.toUpperCase (), null, new new String [] { "TABLE"});
the while (tables.next ()) {
/ **
* return result sets
the database name TABLE_CAT table is located.
TABLE_SCHEM table schema name.
TABLE_NAME Table name.
TABLE_TYPE table type.
* * /
String resTableName = tables.getString ( "TABLE_NAME");
System.out.println (resTableName);
}
} the catch (a ClassNotFoundException E) {
System.out.println ( "loading driver failed!");
} The catch (SQLException E) {
e.printStackTrace ();
}
}
}