get All Column Name from ResultSetMetaData - Java java.sql

Java examples for java.sql:ResultSetMetaData

Description

get All Column Name from ResultSetMetaData

Demo Code


//package com.java2s;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List<String> getAllColumnName(ResultSetMetaData md)
            throws SQLException {
        List<String> array = new ArrayList<String>();
        if (null != md) {
            int cc = md.getColumnCount();
            for (int i = 1; i <= cc; i++) {
                array.add(md.getColumnName(i));
            }//from  w  w  w  .j av a2 s.com
        }

        return array;
    }
}

Related Tutorials