Here you can find the source of getColumnName(boolean isShowRowNum, ResultSet rs)
public static Map<Integer, String> getColumnName(boolean isShowRowNum, ResultSet rs) throws Exception
//package com.java2s; /******************************************************************************* * Copyright (c) 2013 hangum./* w w w . j a v a 2 s .c o m*/ * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * * Contributors: * hangum - initial API and implementation ******************************************************************************/ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.HashMap; import java.util.Map; public class Main { public static Map<Integer, String> getColumnName(boolean isShowRowNum, ResultSet rs) throws Exception { Map<Integer, String> mapColumnName = new HashMap<Integer, String>(); int intStartIndex = 0; if (isShowRowNum) { intStartIndex++; mapColumnName.put(0, "#"); } ResultSetMetaData rsm = rs.getMetaData(); int columnCount = rsm.getColumnCount(); for (int i = 0; i < columnCount; i++) { mapColumnName.put(i + intStartIndex, rsm.getColumnLabel(i + 1)); } return mapColumnName; } public static Map<Integer, String> getColumnName(ResultSet rs) throws Exception { return getColumnName(false, rs); } }