Java examples for JDBC:ResultSet
print ResultSet Data
//package com.java2s; import java.io.PrintWriter; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; public class Main { public static void printResultSetData(PrintWriter writer, ResultSet rset, String delimiter) { try {//from www. j a v a2 s . co m ResultSetMetaData rsetMeta = rset.getMetaData(); int count = rsetMeta.getColumnCount(); while (rset.next()) { for (int i = 1; i < count; i++) { writer.print(rset.getString(i) + delimiter); } writer.println(rset.getString(count)); } } catch (SQLException ex) { throw new RuntimeException(ex.getMessage(), ex); } } }