Here you can find the source of getResultSetRowString(ResultSet rs)
Parameter | Description |
---|---|
rs | non-null result set positioned at a valid row |
Parameter | Description |
---|---|
SQLException | an exception |
public static String getResultSetRowString(ResultSet rs) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { /**/* w w w .j ava 2 s. co m*/ * Turn all columns into one ; delimited seting Primarily useful in * testing that two rows are equivalent * * @param rs non-null result set positioned at a valid row * @return non-null string concatinating all column data * @throws SQLException */ public static String getResultSetRowString(ResultSet rs) throws SQLException { int nCols = getNumberColumns(rs); StringBuffer sb = new StringBuffer(); for (int i = 0; i < nCols; i++) { sb.append(rs.getString(i + 1)); if (i < nCols - 1) sb.append(";"); } return (sb.toString()); } public static int getNumberColumns(ResultSet rs) throws SQLException { ResultSetMetaData md = rs.getMetaData(); int nCols = md.getColumnCount(); return (nCols); } }