Java - ResultSet - 取得所有欄位

Java - ResultSet - 取得所有欄位

	public static HashSet<String> getColumns(ResultSet rs) throws SQLException {
		HashSet<String> columns = new HashSet<String>();
	    ResultSetMetaData rsmd = rs.getMetaData();
	    int count = rsmd.getColumnCount();
	    for (int x = 1; x <= count; x++) {
	    	columns.add(rsmd.getColumnName(x));
	    }
	    return columns;
	}