Here you can find the source of getColumnsNames(ResultSet rs)
public static String[] getColumnsNames(ResultSet rs)
//package com.java2s; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.List; public class Main { public static String[] getColumnsNames(ResultSet rs) { String[] columnNames = null; try {/*from ww w . j a v a 2 s . c o m*/ ResultSetMetaData rsmd = rs.getMetaData(); List<String> lstColumnNames = new ArrayList<String>(); for (int i = 0; i < rsmd.getColumnCount(); i++) { lstColumnNames.add(rsmd.getColumnName(i)); } columnNames = new String[lstColumnNames.size()]; columnNames = lstColumnNames.toArray(columnNames); } catch (Exception e) { e.printStackTrace(); } return columnNames; } }