Java SQL ResultSet Read getHtmlRows(ResultSet results)

Here you can find the source of getHtmlRows(ResultSet results)

Description

get Html Rows

License

Open Source License

Declaration

public static synchronized String getHtmlRows(ResultSet results) throws SQLException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.sql.*;

import java.sql.*;

public class Main {
    public static synchronized String getHtmlRows(ResultSet results) throws SQLException {
        StringBuffer htmlRows = new StringBuffer();
        ResultSetMetaData metaData = results.getMetaData();
        int columnCount = metaData.getColumnCount();

        htmlRows.append("<tr>");
        for (int i = 1; i <= columnCount; i++)
            htmlRows.append("<td><b>" + metaData.getColumnName(i) + "</td>");
        htmlRows.append("</tr>");

        while (results.next()) {
            htmlRows.append("<tr>");
            for (int i = 1; i <= columnCount; i++)
                htmlRows.append("<td>" + results.getString(i) + "</td>");
        }//from  w  ww  .j  a  v  a 2 s  .  c  o  m
        htmlRows.append("</tr>");
        return htmlRows.toString();
    }
}

Related

  1. getFlags(ResultSet rs)
  2. getGeneratedIdFromResultSet(ResultSet resultSet)
  3. getHashMap(ResultSet resultSet)
  4. getHeaders(ResultSetMetaData rsmd)
  5. getHighPrecisionString(ResultSet rs, int ix, int sql_type)
  6. getHtmlTable(ResultSet results)
  7. getId(ResultSet key)
  8. getIndex(ResultSet rs, int index)
  9. getList(ResultSet resultSet, String columnLabel, Class clazz)