Here you can find the source of printResult(ResultSet rs)
public static void printResult(ResultSet rs) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.ResultSet; import java.sql.SQLException; import com.mysql.jdbc.ResultSetMetaData; public class Main { public static void printResult(ResultSet rs) throws SQLException { ResultSetMetaData rsmd = (ResultSetMetaData) rs.getMetaData(); int colNum = rsmd.getColumnCount(); while (rs.next()) { for (int i = 0; i < colNum; i++) System.out.printf(rs.getString(i + 1) + " "); System.out.println(); }//from www . j a va2 s . c om } }