Here you can find the source of getHtmlTable(ResultSet results)
public static String getHtmlTable(ResultSet results) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static String getHtmlTable(ResultSet results) throws SQLException { StringBuilder htmlTable = new StringBuilder(); ResultSetMetaData metaData = results.getMetaData(); int columnCount = metaData.getColumnCount(); htmlTable.append("<table>"); // agregar fila de titulos htmlTable.append("<tr>"); for (int i = 1; i <= columnCount; i++) { htmlTable.append("<th>"); htmlTable.append(metaData.getColumnName(i)); htmlTable.append("</th>"); }// ww w. ja va 2 s. c om htmlTable.append("</tr>"); // agregar otras filas while (results.next()) { htmlTable.append("<tr>"); for (int i = 1; i <= columnCount; i++) { htmlTable.append("<td>"); htmlTable.append(results.getString(i)); htmlTable.append("</td>"); } htmlTable.append("</tr>"); } htmlTable.append("</table>"); return htmlTable.toString(); } }