Here you can find the source of print(ResultSet resultSet)
public static void print(ResultSet resultSet)
//package com.java2s; //License from project: Apache License import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static void print(ResultSet resultSet) { /* Method based on http://stackoverflow.com/a/28165814/3626537 */ try {/*from w w w.j a v a2 s. c om*/ ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); int columnsNumber = resultSetMetaData.getColumnCount(); while (resultSet.next()) { for (int i = 1; i <= columnsNumber; i++) { if (i > 1) System.out.print(", "); String columnValue = resultSet.getString(i); System.out.print(resultSetMetaData.getColumnName(i) + ": " + columnValue); } System.out.println(""); } } catch (SQLException exc) { exc.printStackTrace(); } } }