import java.sql.*; /* * this class is a utility class for ResultSet */ public class ResultSetProcessing { public static void displayStats(ResultSet rs) { // we need a code to dispaly num of columns, no of rows, /* try { if(rs==null) return; int count=0; while (rs.next ()) count++; System.out.println("# of rows: " + count); } catch (SQLException se) { System.out.println("Error in iterating over the ResultSet: in class ResultDisplay"); se.printStackTrace(); } */ } public static int getRowCount(ResultSet rs) { int count=0; try { if(rs==null) { System.out.println("ResultSet null"); return 0; } rs.last(); count = rs.getRow(); rs.beforeFirst(); // reset the cursor to the front, before the first row. } catch (SQLException se) { System.out.println("Error in iterating over the ResultSet: in class ResultDisplay"); se.printStackTrace(); } finally { return count; } } // end of class }