Java SQL Table parse(Connection connection, String tableName, String type)

Here you can find the source of parse(Connection connection, String tableName, String type)

Description

parse

License

Apache License

Declaration

private static List<String> parse(Connection connection, String tableName, String type) 

Method Source Code

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

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

public class Main {
    private static List<String> parse(Connection connection, String tableName, String type) {
        List<String> result = new ArrayList<>();
        try {//from  w  w w. j  a v  a  2s.c  om
            ResultSet resultSet = null;
            if (type.equals("primary")) {
                resultSet = connection.getMetaData().getPrimaryKeys(null, null, tableName);
            } else {
                resultSet = connection.getMetaData().getColumns(null, null, tableName, null);
            }
            while (resultSet.next()) {
                result.add(resultSet.getString("COLUMN_NAME").toLowerCase());//INDEX:4 ,name
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return result;
    }
}

Related

  1. hasTable(String TableName, Connection conn)
  2. isExistsDerbyTable(Connection derbyConnection, String schema, String table)
  3. isFileImportable(File file, String prefix)
  4. isTableEmpty(Connection con, String schemaName, String tableName)
  5. normalizeTableName(String table, Connection con)
  6. queryAllFromTable(String tableName)
  7. quoteSchemaTable(Connection conn, String schema, String table)
  8. truncateTable(Connection conn)
  9. truncateTable(Connection conn, String table_name)