Here you can find the source of getResultSetColnumNames(ResultSet rs)
public static ArrayList<String> getResultSetColnumNames(ResultSet rs) throws SQLException
//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; } }