CachedRowSet and ResultSetMetaData.getXXX() methods
I have created a reporting application in J2EE environment, which uses CachedRowSet and was working just fine. Then I decided to improve this application, in part by using ResultSetMetaData to get things like number of columns, column names, column types, columnlabels, using the getXXX() methods of ResultSetMetaData. Turns out, none of the getXXX() methods seem to work, and others cause very confusing things to happen, ultimately crashing my program. For example:
1.int numberOfColumns = crs.getMetaData().getColumnCount();
2. System.err.println("Number of Columns = "+numberOfColumns);
3.for (int i = 0; i < numberOfColumns; i++){
4.String colClassName = crs.getMetaData().getColumnClassName(i);
5.System.err.println("Column Class Name is "+colClassName);
6.String colName = crs.getMetaData().getColumnName(i);
7.if (colName !=null)
8. System.err.println("Column Name is"+colName);
9.else
10.System.err.println("Column Name is null.");
Line 2 does not even print out, but program execution continues. The program then enters thefor loop, indicating to me thatnumberOfColumns is, in fact, initialized with an int > 0. The program then crashes after line 6. I have never seen such behavior!
What am I doing wrong?
Thanks,
Pat Garner

