Java SQL ResultSet Dump dumpResultSet(ResultSet rs)

Here you can find the source of dumpResultSet(ResultSet rs)

Description

dump Result Set

License

Open Source License

Declaration

public static String dumpResultSet(ResultSet rs) throws SQLException 

Method Source Code


//package com.java2s;
// This package is part of the Spiralcraft project and is licensed under

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

public class Main {
    public static String dumpResultSet(ResultSet rs) throws SQLException {
        ResultSetMetaData md = rs.getMetaData();
        StringBuffer buf = new StringBuffer();

        int count = md.getColumnCount();
        buf.append("\r\n");
        for (int i = 0; i < count; i++) {
            if (i > 0) {
                buf.append(",");
            }/*w  ww .j  a  v  a  2  s  .co  m*/
            buf.append(md.getColumnName(i + 1));
        }

        while (rs.next()) {
            buf.append("\r\n");
            for (int i = 0; i < count; i++) {
                if (i > 0) {
                    buf.append(",");
                }
                buf.append(rs.getObject(i + 1));
            }
        }
        buf.append("\r\n");
        return buf.toString();
    }
}

Related

  1. dump(ResultSet rs)
  2. dump(ResultSet rset)
  3. dump(ResultSet set)
  4. dumpResultSet(ResultSet dbResult)
  5. dumpResultSet(ResultSet resultSet, String tablename, String[] columns)
  6. dumpResultSet(ResultSet rs)
  7. dumpResultSetMetaData(ResultSet dbResult)
  8. dumpRs(ResultSet rs, PrintWriter out, String delimiter, boolean printTrailingDelimiter)