package com.alibaba.druid.pool;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.druid.util.jdbc.ResultSetMetaDataBase;

/**
 * Created by allwefantasy on 8/31/16.
 */
public class ElasticSearchResultSetMetaDataBase extends ResultSetMetaDataBase {
	
    private final List<ColumnMetaData> columns = new ArrayList<ColumnMetaData>();

    public ElasticSearchResultSetMetaDataBase(List<String> headers) {
        for(String column:headers){
            ColumnMetaData columnMetaData = new ColumnMetaData();
            columnMetaData.setColumnLabel(column);
            columnMetaData.setColumnName(column);
            columns.add(columnMetaData);
        }
    }
    
    @Override
    public List<ColumnMetaData> getColumns() {
        return columns;
    }
    
    @Override
    public int getColumnCount() throws SQLException {
        return columns.size();
    }
    
    
}

@@ -800,24 +800,421 @@
 lumns;%0A    %7D
+%0A%0A    @Override%0A    public int findColumn(String columnName) throws SQLException %7B%0A        ColumnMetaData column;%0A        for (int i = 0; i %3C columns.size(); ++i) %7B%0A            column = columns.get(i);%0A            if (column.getColumnName().equals(columnName)) %7B%0A                return i + 1;%0A            %7D%0A        %7D%0A%0A        throw new SQLException(%22column '%22 + columnName + %22' not found.%22);%0A    %7D
 %0A    %0A    @O
@@ -1317,15 +1317,11 @@
  %7D%0A    %0A
-    
 %0A%7D%0A

fix issue #510