Here you can find the source of getColumnNames(final ResultSet resultSet)
Parameter | Description |
---|---|
resultSet | a parameter |
static List<String> getColumnNames(final ResultSet resultSet) throws SQLException
//package com.java2s; /**/*w ww .j a v a2 s.com*/ * Copyright (c) 2011 Martin Geisse * * This file is distributed under the terms of the MIT license. */ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { /** * @param resultSet * @return */ static List<String> getColumnNames(final ResultSet resultSet) throws SQLException { final ResultSetMetaData meta = resultSet.getMetaData(); final List<String> result = new ArrayList<String>(); for (int i = 0; i < meta.getColumnCount(); i++) { result.add(meta.getColumnName(1 + i)); } return result; } }