Java SQL ResultSet Read getResultSetColnumNames(ResultSet rs)

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

Description

get Result Set Colnum Names

License

Open Source License

Declaration

public static ArrayList<String> getResultSetColnumNames(ResultSet rs)
        throws SQLException 

Method Source Code

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

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

public class Main {

    public static ArrayList<String> getResultSetColnumNames(ResultSet rs)
            throws SQLException {
        ArrayList<String> list = null;
        if (rs == null)
            return list;
        list = new ArrayList<String>();
        ResultSetMetaData rsmd = rs.getMetaData();
        int colCount = rsmd.getColumnCount();
        for (int i = 1; i <= colCount; i++) {
            String colName = rsmd.getColumnName(i);
            String colLabel = rsmd.getColumnLabel(i);
            if (colName.equals(colLabel)) {
                list.add(colName);/*from   ww w .jav  a  2  s .c o m*/
            } else {
                list.add(colLabel);
            }
        }
        return list;
    }
}

Related

  1. getResultsAsMap(ResultSet rs)
  2. getResultSet(Connection c, String query)
  3. getResultSet(Connection conn, String query)
  4. getResultSet(Connection connection, String query)
  5. getResultSet(String sql)
  6. getResultSetColumns(ResultSet rs)
  7. getResultSetDateValue(ResultSet rs, String sColumnName)
  8. GetResultSetFromQuery(String command)
  9. getResultSetFromQueryAgainstDefaultConnection( String sql)