Java SQL Table getAllTables(Connection conn)

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

Description

get All Tables

License

Open Source License

Declaration

public static List<String> getAllTables(Connection conn) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private final static String SQL_SHOW_TABLES = "show tables";

    public static List<String> getAllTables(Connection conn) throws SQLException {
        List<String> tableNameList = new ArrayList<String>();
        Statement stmt = null;/* w w w  .j av  a 2 s. c  o m*/
        ResultSet rs = null;

        try {
            stmt = conn.createStatement();
            rs = stmt.executeQuery(SQL_SHOW_TABLES);

            while (rs.next()) {
                tableNameList.add(rs.getString(1));
            }

            return tableNameList;
        } finally {
            try {
                stmt.close();
            } catch (SQLException e) {
            }
        }
    }
}

Related

  1. dumpTable(Connection conn, String TableName, PrintWriter out)
  2. dumpTable(Connection connection, String tablename)
  3. dumpTableToFile(Connection con, String table, String fileName)
  4. exportTableData(String tableName, Connection con)
  5. getAllTableNames(Connection connection)
  6. getBatchResultMessage(String tableName, int rowIdx, int resultCode)
  7. getCount(Connection conn, String tableName)
  8. getIdNumber(String tableName)
  9. getImmutableDefaults()