class DbUtils {

    public static TableData getTableData(Connection connection, String tableName, String schemaName) throws SQLException {
        Objects.requireNonNull(connection, "Connection cannot be null");
        StringValidator.requireNonBlank(tableName, "Table name");
        StringValidator.requireNonBlank(schemaName, "Schema");

        List<String> columnNames = new ArrayList<>();
        List<Integer> columnTypes = new ArrayList<>();
        int dbColumn = -1;
        DatabaseMetaData metaData = connection.getMetaData();
        ResultSet rs = metaData.getColumns(null, schemaName.toUpperCase(), tableName.toUpperCase(), null);
        int index = 0;
        while (rs.next()) {
            String columnName = rs.getString("COLUMN_NAME");
            int columnType = rs.getInt("DATA_TYPE");
            columnNames.add(columnName);
            columnTypes.add(columnType);
            if (columnName.equalsIgnoreCase("DB_ID")) {
                dbColumn = index;
            }
            index++;
        }
        List<Integer> indexColumns = getIndexColumns(connection, columnNames, columnTypes, schemaName, tableName);
        return new TableData(dbColumn, tableName, schemaName, columnNames, columnTypes, indexColumns);
    }

}