此程序都是企业级
的数据库开发程序
全面揭示了JAVA对数据库的操作
源代码在线查看: gettablelist.java
package metadata;
import java.sql.*;
import java.util.*;
import connections.*;
public class GetTableList {
public static void main(String[] args) {
Connection conn = null;
ResultSet rset = null;
try {
conn = ConnectionFactory.getConnection();
DatabaseMetaData dbmd = conn.getMetaData();
String[] types = {
"TABLE"
};
rset = dbmd.getTables(null, "APP", null, types);
Vector v = new Vector();
while (rset.next()) {
String name = rset.getString("TABLE_NAME");
v.add(name);
}
Collections.sort(v);
System.out.println("All tables in schema APP:");
System.out.println(v.toString());
} catch (Exception e) {
e.printStackTrace();
}
finally {
ConnectionFactory.close(rset);
ConnectionFactory.close(conn);
}
}
}