public ResultSet getTables(String catalog,
                           String schemaPattern,
                           String tableNamePattern,
                           String[] types)
                    throws SQLExceptionRetrieves a description of the tables available in the given catalog. Only table descriptions matching the catalog, schema, table name and type criteria are returned. They are ordered by TABLE_TYPE, TABLE_SCHEM and TABLE_NAME. Parameters:
catalog - a catalog name; must match the catalog name as it is stored in the database; "" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search
schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search
tableNamePattern - a table name pattern; must match the table name as it is stored in the database
types - a list of table types to include; null returns all types

解决方案 »

  1.   

    http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String[])class Class1
    {
    public static void main(String[] args) throws Exception
    {
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); 
    java.sql.DatabaseMetaData databaseMetaData = java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://yuer-mobile\\psqlkd;database=Northwind;User=sa;Password=").getMetaData();
    java.sql.ResultSet resultSet = databaseMetaData.getTables(null,null,null,null);
    while (resultSet.next())
    {
    System.out.println( resultSet.getString("TABLE_NAME"));
    }
    }
    }