Java SQL ResultSet Read getFieldsPresentInResultSet(ResultSet rs)

Here you can find the source of getFieldsPresentInResultSet(ResultSet rs)

Description

get Fields Present In Result Set

License

Apache License

Parameter

Parameter Description
rs a parameter

Exception

Parameter Description
SQLException an exception

Return

a list of lower case column names present in the result set.

Declaration

public static List<String> getFieldsPresentInResultSet(ResultSet rs)
        throws SQLException 

Method Source Code

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

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

public class Main {
    /**//from w  ww  . ja va2  s.  c om
     * @param rs
     * @return a list of lower case column names present in the result set.
     * @throws SQLException
     */
    public static List<String> getFieldsPresentInResultSet(ResultSet rs)
            throws SQLException {
        List<String> fieldsPresentInResultSet = new ArrayList<String>();
        ResultSetMetaData metaData = rs.getMetaData();
        for (int index = 1; index <= metaData.getColumnCount(); index++) {
            fieldsPresentInResultSet.add(metaData.getColumnLabel(index)
                    .toLowerCase());
        }
        return fieldsPresentInResultSet;
    }
}

Related

  1. getEnum(ResultSet rs, int index, Class type)
  2. getEnumFromResultSet(ResultSet rset, Enum field, T[] enumValues)
  3. getExpectedType(ResultSet resultSet, int columnIndex)
  4. getExplainPlan(ResultSet rs)
  5. getFieldNames(ResultSet rs)
  6. getFirstGeometryFieldIndex(ResultSet resultSet)
  7. getFirstInt(ResultSet resultSet)
  8. getFlags(ResultSet rs)
  9. getGeneratedIdFromResultSet(ResultSet resultSet)