Here you can find the source of printHeader(PrintWriter pw, ResultSet rs)
public static void printHeader(PrintWriter pw, ResultSet rs) throws SQLException
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static void printHeader(PrintWriter pw, ResultSet rs) throws SQLException { ResultSetMetaData rsmd = rs.getMetaData(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { pw.print((i == 1 ? rsmd.getColumnName(i) : "\t" + rsmd.getColumnName(i))); }// w w w. ja va 2 s. co m pw.println(); } }