Java SQL Table getTableList(Connection connection)

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

Description

get Table List

License

Open Source License

Declaration

public static ArrayList<String> getTableList(Connection connection) throws SQLException 

Method Source Code

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

import java.sql.*;
import java.util.ArrayList;

public class Main {
    public static ArrayList<String> getTableList(Connection connection) throws SQLException {

        String request = "SELECT * FROM sqlite_master;";

        Statement stmt = connection.createStatement();

        ResultSet results = stmt.executeQuery(request);
        ResultSetMetaData resultsMtdt = results.getMetaData();

        ArrayList<String> tables = new ArrayList<>();

        while (results.next()) {

            Object obj = results.getObject(1);
            if (obj != null && obj instanceof String) {
                String type = obj.toString();
                if (type.indexOf("table") != -1) {
                    tables.add(results.getObject(2).toString());
                }/*  w w  w.ja  v a 2 s.c om*/
            }
        }

        return tables;
    }
}

Related

  1. getNextId(Connection con, String table, String identityFieldName)
  2. getRowCount(Statement stmt, String tableName)
  3. getSensorsList( final Connection jdbcConnection, String tableName)
  4. getShapeText(Connection conn, String tableName)
  5. getTableFields(Connection con, String tableName)
  6. getTableName(String sql)
  7. getTableNames(Connection conn)
  8. getTableNames(Connection conn)
  9. getTables(Connection conn)