Java JDBC Database Metadata getAllTables(Connection connection)

Here you can find the source of getAllTables(Connection connection)

Description

get All Tables

License

Apache License

Declaration

public static Set<String> getAllTables(Connection connection) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Connection;
import java.sql.DatabaseMetaData;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static Set<String> getAllTables(Connection connection) throws SQLException {
        Set<String> tables = new HashSet<String>();
        DatabaseMetaData db = connection.getMetaData();
        ResultSet rs = db.getTables(null, null, "%", new String[] { "TABLE" });
        while (rs.next()) {
            tables.add(rs.getString(3));
        }//from   w  ww. jav a2 s  . c  o m
        return tables;
    }
}

Related

  1. adjustIdentifierCase(String identifier, Connection conn)
  2. createHsqlPlSchemaIfNecessary(Connection con)
  3. getAllTables(Connection connection)
  4. getCatalogs(Connection c)
  5. getColumnDefaultValue(DatabaseMetaData metaData, String tableName, String columnName)
  6. getColumnNames(Connection connection, String tableName)
  7. getColumnNames(String tablename, String column, Connection conn)