|
I am using the AS400JDBCDriver(). The system property is set to an AS400 object. Using the connect() method to obtain the connection. After the connection is made, here is the code: Statement SQLStatement = getJDBCConnectionObject().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = SQLStatement.executeQuery(getJEditorPane1().getSelectedText()); ResultSetTableModel ScrollRSModel = new ResultSetTableModel(resultSet); System.out.println(ScrollRSModel.getRowCount()); -----Original Message----- From: Dave Wall [mailto:dawall@us.ibm.com] Sent: Tuesday, May 21, 2002 10:38 AM To: java400-l@midrange.com Subject: RE: Custom Table Model. I see your code contains getResultSet().last(); return getResultSet().getRow(); What JDBC driver are you using? The Toolbox JDBC driver does not support getRow() after a cursor movement based on the end of the result set (like last()) until JTOpen 3.0 / V5R2. David Wall Toolbox for Java iSeries ODBC Driver for Linux "Mangavalli, Ramanujam" To: "'java400-l@midrange.com'" <java400-l@midrange.com> <RamM@Mvmills.com cc: > Subject: RE: Custom Table Model. Sent by: java400-l-admin@m idrange.com 05/21/2002 09:19 AM Please respond to java400-l 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; } } _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
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.