|
Well, here is the code: (getRowCount() returns 0). public class ResultSetTableModel extends AbstractTableModel { private java.sql.ResultSet lResultSet; private java.sql.ResultSetMetaData lResultSetMetaData; protected final java.lang.String className = "ResultSetTableModel"; /** * Insert the method's description here. * Creation date: (5/17/2002 2:12:05 PM) * @param pResultSet java.sql.ResultSet */ public ResultSetTableModel(ResultSet pResultSet) { setResultSet(pResultSet); try { lResultSetMetaData = lResultSet.getMetaData(); } catch (Throwable thrownException) { System.out.println("Error occurred in class " + className + " in constructor.\n"); thrownException.printStackTrace(); } } /** * Insert the method's description here. * Creation date: (5/17/2002 2:31:24 PM) * @return int */ public int getColumnCount() { try { return lResultSetMetaData.getColumnCount(); } catch (Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in class name " + className + " in method getColumnCount()"); return 0; } } /** * Insert the method's description here. * Creation date: (5/17/2002 2:21:03 PM) * @return java.lang.String * @param pColumnNumber int */ public String getColumnName(int pColumnNumber) { try { return lResultSetMetaData.getColumnName(pColumnNumber + 1); } catch(Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in class name " + className + " in method getColumnName(int pColumnNumber"); return new Integer(pColumnNumber).toString(); } } /** * Insert the method's description here. * Creation date: (5/17/2002 2:19:18 PM) * @return java.sql.ResultSetMetaData */ protected java.sql.ResultSetMetaData getLResultSetMetaData() { return lResultSetMetaData; } /** * Insert the method's description here. * Creation date: (5/17/2002 2:18:40 PM) * @return java.sql.ResultSet */ protected java.sql.ResultSet getResultSet() { return lResultSet; } /** * getRowCount method comment. */ public int getRowCount() { try { getResultSet().last(); return getResultSet().getRow(); } catch (Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in class name ScrollableResultSetTableModel in method getValueAt()"); thrownException.printStackTrace(); } return 0; } /** * getValueAt method comment. */ public Object getValueAt(int pRow, int pColumn) { try { ResultSet lScrollableResultSet =getResultSet(); //lScrollableResultSet.absolute(pRow + 1); lScrollableResultSet.next(); System.out.println((String)lScrollableResultSet.getObject(pColumn+1)); return lScrollableResultSet.getObject(pColumn+1); } catch (Throwable thrownException) { System.out.println(thrownException.getMessage()); System.out.println("Error occurred in class name ScrollableResultSetTableModel in method getValueAt()"); System.out.println("Parameters passed to method are row = " + pRow + ", column = " + pColumn); thrownException.printStackTrace(); return null; } } /** * Insert the method's description here. * Creation date: (5/17/2002 2:18:40 PM) * @param newLResultSet java.sql.ResultSet */ protected void setResultSet(java.sql.ResultSet newLResultSet) { lResultSet = newLResultSet; } /** * Insert the method's description here. * Creation date: (5/17/2002 2:19:18 PM) * @param newLResultSetMetaData java.sql.ResultSetMetaData */ protected void setResultSetMetaData(java.sql.ResultSetMetaData newLResultSetMetaData) { lResultSetMetaData = newLResultSetMetaData; } }
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.