KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > tools > SimpleResultSet


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.tools;
6
7 import java.io.InputStream JavaDoc;
8 import java.io.Reader JavaDoc;
9 import java.math.BigDecimal JavaDoc;
10 import java.net.URL JavaDoc;
11 import java.sql.*;
12 import java.util.ArrayList JavaDoc;
13 import java.util.Calendar JavaDoc;
14 import java.util.Map JavaDoc;
15
16 /**
17  * This class is a simple result set and meta data implementation.
18  * It can be used in Java functions that return a result set.
19  * Only the most basic methods are implemented, the others throw an exception.
20  * This implementation is standalone, and only relies on standard classes.
21  * It can be extended easily if required.
22  *
23  * An application can create a result set using the following code:
24  *
25  * <pre>
26  * SimpleResultSet rs = new SimpleResultSet();
27  * rs.addColumn(&quot;ID&quot;, Types.INTEGER, 10, 0);
28  * rs.addColumn(&quot;NAME&quot;, Types.VARCHAR, 255, 0);
29  * rs.addRow(new Object[] { new Integer(0), &quot;Hello&quot; });
30  * rs.addRow(new Object[] { new Integer(1), &quot;World&quot; });
31  * </pre>
32  *
33  */

34 public class SimpleResultSet implements ResultSet, ResultSetMetaData {
35
36     private ArrayList JavaDoc rows;
37     private Object JavaDoc[] currentRow;
38     private int rowId = -1;
39     private boolean wasNull;
40     private SimpleRowSource source;
41     private ArrayList JavaDoc columns = new ArrayList JavaDoc();
42
43     private static class Column {
44         String JavaDoc name;
45         int sqlType;
46         int precision;
47         int scale;
48     }
49
50     /**
51      * This constructor is used if the result set is later populated with addRow.
52      */

53     public SimpleResultSet() {
54         rows = new ArrayList JavaDoc();
55     }
56
57     /**
58      * This constructor is used if the result set should retrieve the rows using the specified
59      * row source object.
60      *
61      * @param source the row source
62      */

63     public SimpleResultSet(SimpleRowSource source) {
64         this.source = source;
65     }
66
67     /**
68      * Adds a column to the result set.
69      *
70      * @param name null is replaced with C1, C2,...
71      * @param sqlType the value returned in getColumnType(..) (ignored internally)
72      * @param precision the precision
73      * @param scale the scale
74      * @throws SQLException
75      */

76     public void addColumn(String JavaDoc name, int sqlType, int precision, int scale) throws SQLException {
77         if (rows != null && rows.size() > 0) {
78             throw new SQLException("Cannot add a column after adding rows", "21S02");
79         }
80         if (name == null) {
81             name = "C" + (columns.size() + 1);
82         }
83         Column column = new Column();
84         column.name = name;
85         column.sqlType = sqlType;
86         column.precision = precision;
87         column.scale = scale;
88         columns.add(column);
89     }
90
91     /**
92      * Add a new row to the result set.
93      *
94      * @param row the row as an array of objects
95      */

96     public void addRow(Object JavaDoc[] row) throws SQLException {
97         if(rows == null) {
98             throw new SQLException("Cannot add a row when using RowSource", "21S02");
99         }
100         rows.add(row);
101     }
102
103     /**
104      * Returns ResultSet.CONCUR_READ_ONLY.
105      *
106      * @return CONCUR_READ_ONLY
107      */

108     public int getConcurrency() throws SQLException {
109         return ResultSet.CONCUR_READ_ONLY;
110     }
111
112     /**
113      * Returns ResultSet.FETCH_FORWARD.
114      *
115      * @return FETCH_FORWARD
116      */

117     public int getFetchDirection() throws SQLException {
118         return ResultSet.FETCH_FORWARD;
119     }
120
121     /**
122      * Returns 0.
123      *
124      * @return 0
125      */

126     public int getFetchSize() throws SQLException {
127         return 0;
128     }
129
130     /**
131      * Returns the row number (1, 2,...) or 0 for no row.
132      *
133      * @return 0
134      */

135     public int getRow() throws SQLException {
136         return rowId + 1;
137     }
138
139     /**
140      * Returns ResultSet.TYPE_FORWARD_ONLY.
141      *
142      * @return TYPE_FORWARD_ONLY
143      */

144     public int getType() throws SQLException {
145         return ResultSet.TYPE_FORWARD_ONLY;
146     }
147
148     /**
149      * Closes the result set and releases the resources.
150      */

151     public void close() throws SQLException {
152         currentRow = null;
153         rows = null;
154         columns = null;
155         rowId = -1;
156         if(source != null) {
157             source.close();
158             source = null;
159         }
160     }
161
162     /**
163      * Moves the cursor to the next row of the result set.
164      *
165      * @return true if successfull, false if there are no more rows
166      */

167     public boolean next() throws SQLException {
168         if (source != null) {
169             rowId++;
170             currentRow = source.readRow();
171             if(currentRow != null) {
172                 return true;
173             }
174         } else if (rows != null && rowId < rows.size()) {
175             rowId++;
176             if (rowId < rows.size()) {
177                 currentRow = (Object JavaDoc[]) rows.get(rowId);
178                 return true;
179             }
180         }
181         close();
182         return false;
183     }
184     
185     /**
186      * Moves the current position to before the first row, that means resets the result set.
187      *
188      * @throws SQLException is this method is not supported
189      */

190     public void beforeFirst() throws SQLException {
191         rowId = -1;
192         if(source != null) {
193             source.reset();
194         }
195     }
196
197     /**
198      * Returns whether the last column accessed was a null value.
199      *
200      * @return true if the last column accessed was a null value
201      */

202     public boolean wasNull() throws SQLException {
203         return wasNull;
204     }
205
206     /**
207      * Returns value as an byte.
208      *
209      * @return the value
210      */

211     public byte getByte(int columnIndex) throws SQLException {
212         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
213         return v == null ? 0 : v.byteValue();
214     }
215
216     /**
217      * Returns value as an double.
218      *
219      * @return the value
220      */

221     public double getDouble(int columnIndex) throws SQLException {
222         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
223         return v == null ? 0 : v.doubleValue();
224     }
225
226     /**
227      * Returns value as a float.
228      *
229      * @return the value
230      */

231     public float getFloat(int columnIndex) throws SQLException {
232         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
233         return v == null ? 0 : v.floatValue();
234     }
235
236     /**
237      * Returns value as an int.
238      *
239      * @return the value
240      */

241     public int getInt(int columnIndex) throws SQLException {
242         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
243         return v == null ? 0 : v.intValue();
244     }
245
246     /**
247      * Returns value as a long.
248      *
249      * @return the value
250      */

251     public long getLong(int columnIndex) throws SQLException {
252         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
253         return v == null ? 0 : v.longValue();
254     }
255
256     /**
257      * Returns value as a short.
258      *
259      * @return the value
260      */

261     public short getShort(int columnIndex) throws SQLException {
262         Number JavaDoc v = (Number JavaDoc) get(columnIndex);
263         return v == null ? 0 : v.shortValue();
264     }
265
266     /**
267      * Returns value as a boolean.
268      *
269      * @return the value
270      */

271     public boolean getBoolean(int columnIndex) throws SQLException {
272         Boolean JavaDoc v = (Boolean JavaDoc) get(columnIndex);
273         return v == null ? false : v.booleanValue();
274     }
275
276     /**
277      * Returns value as a byte array.
278      *
279      * @return the value
280      */

281     public byte[] getBytes(int columnIndex) throws SQLException {
282         return (byte[]) get(columnIndex);
283     }
284
285     /**
286      * Returns value as an Object.
287      *
288      * @return the value
289      */

290     public Object JavaDoc getObject(int columnIndex) throws SQLException {
291         return get(columnIndex);
292     }
293
294     /**
295      * Returns value as a String.
296      *
297      * @return the value
298      */

299     public String JavaDoc getString(int columnIndex) throws SQLException {
300         Object JavaDoc o = get(columnIndex);
301         return o == null ? null : o.toString();
302     }
303
304     /**
305      * Returns value as a byte.
306      *
307      * @return the value
308      */

309     public byte getByte(String JavaDoc columnName) throws SQLException {
310         Number JavaDoc v = (Number JavaDoc) get(columnName);
311         return v == null ? 0 : v.byteValue();
312     }
313
314     /**
315      * Returns value as a double.
316      *
317      * @return the value
318      */

319     public double getDouble(String JavaDoc columnName) throws SQLException {
320         Number JavaDoc v = (Number JavaDoc) get(columnName);
321         return v == null ? 0 : v.doubleValue();
322     }
323
324     /**
325      * Returns value as a float.
326      *
327      * @return the value
328      */

329     public float getFloat(String JavaDoc columnName) throws SQLException {
330         Number JavaDoc v = (Number JavaDoc) get(columnName);
331         return v == null ? 0 : v.floatValue();
332     }
333
334     /**
335      * Searches for a specific column in the result set. A case-insensitive search is made.
336      *
337      * @param columnName the name of the column label
338      * @return the column index (1,2,...)
339      * @throws SQLException if the column is not found or if the result set is closed
340      */

341     public int findColumn(String JavaDoc columnName) throws SQLException {
342         for (int i = 0; columnName != null && columns != null && i < columns.size(); i++) {
343             if (columnName.equalsIgnoreCase(getColumn(i).name)) {
344                 return i + 1;
345             }
346         }
347         throw new SQLException("Column not found: " + columnName, "42S22");
348     }
349
350     /**
351      * Returns value as an int.
352      *
353      * @return the value
354      */

355     public int getInt(String JavaDoc columnName) throws SQLException {
356         Number JavaDoc v = (Number JavaDoc) get(columnName);
357         return v == null ? 0 : v.intValue();
358     }
359
360     /**
361      * Returns value as a long.
362      *
363      * @return the value
364      */

365     public long getLong(String JavaDoc columnName) throws SQLException {
366         Number JavaDoc v = (Number JavaDoc) get(columnName);
367         return v == null ? 0 : v.longValue();
368     }
369
370     /**
371      * Returns value as a short.
372      *
373      * @return the value
374      */

375     public short getShort(String JavaDoc columnName) throws SQLException {
376         Number JavaDoc v = (Number JavaDoc) get(columnName);
377         return v == null ? 0 : v.shortValue();
378     }
379
380     /**
381      * Returns value as a boolean.
382      *
383      * @return the value
384      */

385     public boolean getBoolean(String JavaDoc columnName) throws SQLException {
386         Boolean JavaDoc v = (Boolean JavaDoc) get(columnName);
387         return v == null ? false : v.booleanValue();
388     }
389
390     /**
391      * Returns value as a byte array.
392      *
393      * @return the value
394      */

395     public byte[] getBytes(String JavaDoc columnName) throws SQLException {
396         return (byte[]) get(columnName);
397     }
398
399     /**
400      * Returns value as a java.math.BigDecimal.
401      *
402      * @return the value
403      */

404     public BigDecimal JavaDoc getBigDecimal(int columnIndex) throws SQLException {
405         return (BigDecimal JavaDoc) get(columnIndex);
406     }
407
408     /**
409      * Returns value as an java.sql.Date.
410      *
411      * @return the value
412      */

413     public Date getDate(int columnIndex) throws SQLException {
414         return (Date) get(columnIndex);
415     }
416
417     /**
418      * Returns a reference to itself.
419      *
420      * @return this
421      */

422     public ResultSetMetaData getMetaData() throws SQLException {
423         return this;
424     }
425
426     /**
427      * Returns null.
428      *
429      * @return null
430      */

431     public SQLWarning getWarnings() throws SQLException {
432         return null;
433     }
434
435     /**
436      * Returns null.
437      *
438      * @return null
439      */

440     public Statement getStatement() throws SQLException {
441         return null;
442     }
443
444     /**
445      * Returns value as an java.sql.Time.
446      *
447      * @return the value
448      */

449     public Time getTime(int columnIndex) throws SQLException {
450         return (Time) get(columnIndex);
451     }
452
453     /**
454      * Returns value as an java.sql.Timestamp.
455      *
456      * @return the value
457      */

458     public Timestamp getTimestamp(int columnIndex) throws SQLException {
459         return (Timestamp) get(columnIndex);
460     }
461
462     /**
463      * Returns value as an Object.
464      *
465      * @return the value
466      */

467     public Object JavaDoc getObject(String JavaDoc columnName) throws SQLException {
468         return get(columnName);
469     }
470
471     /**
472      * Returns value as a String.
473      *
474      * @return the value
475      */

476     public String JavaDoc getString(String JavaDoc columnName) throws SQLException {
477         Object JavaDoc o = get(columnName);
478         return o == null ? null : o.toString();
479     }
480
481     /**
482      * Returns value as a java.math.BigDecimal.
483      *
484      * @return the value
485      */

486     public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName) throws SQLException {
487         return (BigDecimal JavaDoc) get(columnName);
488     }
489
490     /**
491      * Returns value as a java.sql.Date.
492      *
493      * @return the value
494      */

495     public Date getDate(String JavaDoc columnName) throws SQLException {
496         return (Date) get(columnName);
497     }
498
499     /**
500      * Returns value as a java.sql.Time.
501      *
502      * @return the value
503      */

504     public Time getTime(String JavaDoc columnName) throws SQLException {
505         return (Time) get(columnName);
506     }
507
508     /**
509      * Returns value as a java.sql.Timestamp.
510      *
511      * @return the value
512      */

513     public Timestamp getTimestamp(String JavaDoc columnName) throws SQLException {
514         return (Timestamp) get(columnName);
515     }
516
517     // ---- result set meta data ---------------------------------------------
518

519     /**
520      * Returns the column count.
521      *
522      * @return the column count
523      */

524     public int getColumnCount() throws SQLException {
525         return columns.size();
526     }
527
528     /**
529      * Returns 15.
530      *
531      * @return 15
532      */

533     public int getColumnDisplaySize(int columnIndex) throws SQLException {
534         return 15;
535     }
536
537     /**
538      * Returns the SQL type.
539      *
540      * @return the SQL type
541      */

542     public int getColumnType(int columnIndex) throws SQLException {
543         return getColumn(columnIndex - 1).sqlType;
544     }
545
546     /**
547      * Returns the precision.
548      *
549      * @return the precision
550      */

551     public int getPrecision(int columnIndex) throws SQLException {
552         return getColumn(columnIndex - 1).precision;
553     }
554
555     /**
556      * Returns the scale.
557      *
558      * @return the scale
559      */

560     public int getScale(int columnIndex) throws SQLException {
561         return getColumn(columnIndex - 1).scale;
562     }
563
564     /**
565      * Returns ResultSetMetaData.columnNullableUnknown.
566      *
567      * @return columnNullableUnknown
568      */

569     public int isNullable(int columnIndex) throws SQLException {
570         return ResultSetMetaData.columnNullableUnknown;
571     }
572
573     /**
574      * Returns false.
575      *
576      * @return false
577      */

578     public boolean isAutoIncrement(int columnIndex) throws SQLException {
579         return false;
580     }
581
582     /**
583      * Returns true.
584      *
585      * @return true
586      */

587     public boolean isCaseSensitive(int columnIndex) throws SQLException {
588         return true;
589     }
590
591     /**
592      * Returns false.
593      *
594      * @return false
595      */

596     public boolean isCurrency(int columnIndex) throws SQLException {
597         return false;
598     }
599
600     /**
601      * Returns false.
602      *
603      * @return false
604      */

605     public boolean isDefinitelyWritable(int columnIndex) throws SQLException {
606         return false;
607     }
608
609     /**
610      * Returns true.
611      *
612      * @return true
613      */

614     public boolean isReadOnly(int columnIndex) throws SQLException {
615         return true;
616     }
617
618     /**
619      * Returns true.
620      *
621      * @return true
622      */

623     public boolean isSearchable(int columnIndex) throws SQLException {
624         return true;
625     }
626
627     /**
628      * Returns true.
629      *
630      * @return true
631      */

632     public boolean isSigned(int columnIndex) throws SQLException {
633         return true;
634     }
635
636     /**
637      * Returns false.
638      *
639      * @return false
640      */

641     public boolean isWritable(int columnIndex) throws SQLException {
642         return false;
643     }
644
645     /**
646      * Returns null.
647      *
648      * @return null
649      */

650     public String JavaDoc getCatalogName(int columnIndex) throws SQLException {
651         return null;
652     }
653
654     /**
655      * Returns null.
656      *
657      * @return null
658      */

659     public String JavaDoc getColumnClassName(int columnIndex) throws SQLException {
660         return null;
661     }
662
663     /**
664      * Returns the column name.
665      *
666      * @return the column name
667      */

668     public String JavaDoc getColumnLabel(int columnIndex) throws SQLException {
669         return getColumn(columnIndex - 1).name;
670     }
671
672     /**
673      * Returns the column name.
674      *
675      * @return the column name
676      */

677     public String JavaDoc getColumnName(int columnIndex) throws SQLException {
678         return getColumnLabel(columnIndex);
679     }
680
681     /**
682      * Returns null.
683      *
684      * @return null
685      */

686     public String JavaDoc getColumnTypeName(int columnIndex) throws SQLException {
687         return null;
688     }
689
690     /**
691      * Returns null.
692      *
693      * @return null
694      */

695     public String JavaDoc getSchemaName(int columnIndex) throws SQLException {
696         return null;
697     }
698
699     /**
700      * Returns null.
701      *
702      * @return null
703      */

704     public String JavaDoc getTableName(int columnIndex) throws SQLException {
705         return null;
706     }
707
708     // ---- unsupported / result set ---------------------------------------------
709

710     /** INTERNAL */
711     public void clearWarnings() throws SQLException {
712     }
713
714     /** INTERNAL */
715     public void afterLast() throws SQLException {
716         throw getUnsupportedException();
717     }
718
719     /** INTERNAL */
720     public void cancelRowUpdates() throws SQLException {
721         throw getUnsupportedException();
722     }
723
724     /** INTERNAL */
725     public void updateNull(String JavaDoc columnName) throws SQLException {
726         throw getUnsupportedException();
727     }
728
729     /** INTERNAL */
730     public void deleteRow() throws SQLException {
731         throw getUnsupportedException();
732     }
733
734     /** INTERNAL */
735     public void insertRow() throws SQLException {
736         throw getUnsupportedException();
737     }
738
739     /** INTERNAL */
740     public void moveToCurrentRow() throws SQLException {
741         throw getUnsupportedException();
742     }
743
744     /** INTERNAL */
745     public void moveToInsertRow() throws SQLException {
746         throw getUnsupportedException();
747     }
748
749     /** INTERNAL */
750     public void refreshRow() throws SQLException {
751         throw getUnsupportedException();
752     }
753
754     /** INTERNAL */
755     public void updateRow() throws SQLException {
756         throw getUnsupportedException();
757     }
758
759     /** INTERNAL */
760     public boolean first() throws SQLException {
761         throw getUnsupportedException();
762     }
763
764     /** INTERNAL */
765     public boolean isAfterLast() throws SQLException {
766         throw getUnsupportedException();
767     }
768
769     /** INTERNAL */
770     public boolean isBeforeFirst() throws SQLException {
771         throw getUnsupportedException();
772     }
773
774     /** INTERNAL */
775     public boolean isFirst() throws SQLException {
776         throw getUnsupportedException();
777     }
778
779     /** INTERNAL */
780     public boolean isLast() throws SQLException {
781         throw getUnsupportedException();
782     }
783
784     /** INTERNAL */
785     public boolean last() throws SQLException {
786         throw getUnsupportedException();
787     }
788
789     /** INTERNAL */
790     public boolean previous() throws SQLException {
791         throw getUnsupportedException();
792     }
793
794     /** INTERNAL */
795     public boolean rowDeleted() throws SQLException {
796         throw getUnsupportedException();
797     }
798
799     /** INTERNAL */
800     public boolean rowInserted() throws SQLException {
801         throw getUnsupportedException();
802     }
803
804     /** INTERNAL */
805     public boolean rowUpdated() throws SQLException {
806         throw getUnsupportedException();
807     }
808
809     /** INTERNAL */
810     public void setFetchDirection(int direction) throws SQLException {
811         throw getUnsupportedException();
812     }
813
814     /** INTERNAL */
815     public void setFetchSize(int rows) throws SQLException {
816         throw getUnsupportedException();
817     }
818
819     /** INTERNAL */
820     public void updateNull(int columnIndex) throws SQLException {
821         throw getUnsupportedException();
822     }
823
824     /** INTERNAL */
825     public boolean absolute(int row) throws SQLException {
826         throw getUnsupportedException();
827     }
828
829     /** INTERNAL */
830     public boolean relative(int rows) throws SQLException {
831         throw getUnsupportedException();
832     }
833
834     /** INTERNAL */
835     public void updateByte(int columnIndex, byte x) throws SQLException {
836         throw getUnsupportedException();
837     }
838
839     /** INTERNAL */
840     public void updateDouble(int columnIndex, double x) throws SQLException {
841         throw getUnsupportedException();
842     }
843
844     /** INTERNAL */
845     public void updateFloat(int columnIndex, float x) throws SQLException {
846         throw getUnsupportedException();
847     }
848
849     /** INTERNAL */
850     public void updateInt(int columnIndex, int x) throws SQLException {
851         throw getUnsupportedException();
852     }
853
854     /** INTERNAL */
855     public void updateLong(int columnIndex, long x) throws SQLException {
856         throw getUnsupportedException();
857     }
858
859     /** INTERNAL */
860     public void updateShort(int columnIndex, short x) throws SQLException {
861         throw getUnsupportedException();
862     }
863
864     /** INTERNAL */
865     public void updateBoolean(int columnIndex, boolean x) throws SQLException {
866         throw getUnsupportedException();
867     }
868
869     /** INTERNAL */
870     public void updateBytes(int columnIndex, byte[] x) throws SQLException {
871         throw getUnsupportedException();
872     }
873
874     /** INTERNAL */
875     public InputStream JavaDoc getAsciiStream(int columnIndex) throws SQLException {
876         return null;
877     }
878
879     /** INTERNAL */
880     public InputStream JavaDoc getBinaryStream(int columnIndex) throws SQLException {
881         return null;
882     }
883
884     /** @deprecated INTERNAL */
885     public InputStream JavaDoc getUnicodeStream(int columnIndex) throws SQLException {
886         return null;
887     }
888
889     /** INTERNAL */
890     public void updateAsciiStream(int columnIndex, InputStream JavaDoc x, int length) throws SQLException {
891         throw getUnsupportedException();
892     }
893
894     /** INTERNAL */
895     public void updateBinaryStream(int columnIndex, InputStream JavaDoc x, int length) throws SQLException {
896         throw getUnsupportedException();
897     }
898
899     /** INTERNAL */
900     public Reader JavaDoc getCharacterStream(int columnIndex) throws SQLException {
901         throw getUnsupportedException();
902     }
903
904     /** INTERNAL */
905     public void updateCharacterStream(int columnIndex, Reader JavaDoc x, int length) throws SQLException {
906         throw getUnsupportedException();
907     }
908
909     /** INTERNAL */
910     public void updateObject(int columnIndex, Object JavaDoc x) throws SQLException {
911         throw getUnsupportedException();
912     }
913
914     /** INTERNAL */
915     public void updateObject(int columnIndex, Object JavaDoc x, int scale) throws SQLException {
916         throw getUnsupportedException();
917     }
918
919     /** INTERNAL */
920     public String JavaDoc getCursorName() throws SQLException {
921         throw getUnsupportedException();
922     }
923
924     /** INTERNAL */
925     public void updateString(int columnIndex, String JavaDoc x) throws SQLException {
926         throw getUnsupportedException();
927     }
928
929     /** INTERNAL */
930     public void updateByte(String JavaDoc columnName, byte x) throws SQLException {
931         throw getUnsupportedException();
932     }
933
934     /** INTERNAL */
935     public void updateDouble(String JavaDoc columnName, double x) throws SQLException {
936         throw getUnsupportedException();
937     }
938
939     /** INTERNAL */
940     public void updateFloat(String JavaDoc columnName, float x) throws SQLException {
941         throw getUnsupportedException();
942     }
943
944     /** INTERNAL */
945     public void updateInt(String JavaDoc columnName, int x) throws SQLException {
946         throw getUnsupportedException();
947     }
948
949     /** INTERNAL */
950     public void updateLong(String JavaDoc columnName, long x) throws SQLException {
951         throw getUnsupportedException();
952     }
953
954     /** INTERNAL */
955     public void updateShort(String JavaDoc columnName, short x) throws SQLException {
956         throw getUnsupportedException();
957     }
958
959     /** INTERNAL */
960     public void updateBoolean(String JavaDoc columnName, boolean x) throws SQLException {
961         throw getUnsupportedException();
962     }
963
964     /** INTERNAL */
965     public void updateBytes(String JavaDoc columnName, byte[] x) throws SQLException {
966         throw getUnsupportedException();
967     }
968
969     /** @deprecated INTERNAL */
970     public BigDecimal JavaDoc getBigDecimal(int columnIndex, int scale) throws SQLException {
971         throw getUnsupportedException();
972     }
973
974     /** INTERNAL */
975     public void updateBigDecimal(int columnIndex, BigDecimal JavaDoc x) throws SQLException {
976         throw getUnsupportedException();
977     }
978
979     /** INTERNAL */
980     public URL JavaDoc getURL(int columnIndex) throws SQLException {
981         throw getUnsupportedException();
982     }
983
984     /** INTERNAL */
985     public Array getArray(int i) throws SQLException {
986         throw getUnsupportedException();
987     }
988
989     /** INTERNAL */
990     public void updateArray(int columnIndex, Array x) throws SQLException {
991         throw getUnsupportedException();
992     }
993
994     /** INTERNAL */
995     public Blob getBlob(int i) throws SQLException {
996         throw getUnsupportedException();
997     }
998
999     /** INTERNAL */
1000    public void updateBlob(int columnIndex, Blob x) throws SQLException {
1001        throw getUnsupportedException();
1002    }
1003
1004    /** INTERNAL */
1005    public Clob getClob(int i) throws SQLException {
1006        throw getUnsupportedException();
1007    }
1008
1009    /** INTERNAL */
1010    public void updateClob(int columnIndex, Clob x) throws SQLException {
1011        throw getUnsupportedException();
1012    }
1013
1014    /** INTERNAL */
1015    public void updateDate(int columnIndex, Date x) throws SQLException {
1016        throw getUnsupportedException();
1017    }
1018
1019    /** INTERNAL */
1020    public Ref getRef(int i) throws SQLException {
1021        throw getUnsupportedException();
1022    }
1023
1024    /** INTERNAL */
1025    public void updateRef(int columnIndex, Ref x) throws SQLException {
1026        throw getUnsupportedException();
1027    }
1028
1029    /** INTERNAL */
1030    public void updateTime(int columnIndex, Time x) throws SQLException {
1031        throw getUnsupportedException();
1032    }
1033
1034    /** INTERNAL */
1035    public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
1036        throw getUnsupportedException();
1037    }
1038
1039    /** INTERNAL */
1040    public InputStream JavaDoc getAsciiStream(String JavaDoc columnName) throws SQLException {
1041        throw getUnsupportedException();
1042    }
1043
1044    /** INTERNAL */
1045    public InputStream JavaDoc getBinaryStream(String JavaDoc columnName) throws SQLException {
1046        throw getUnsupportedException();
1047    }
1048
1049    /** @deprecated INTERNAL */
1050    public InputStream JavaDoc getUnicodeStream(String JavaDoc columnName) throws SQLException {
1051        throw getUnsupportedException();
1052    }
1053
1054    /** INTERNAL */
1055    public void updateAsciiStream(String JavaDoc columnName, InputStream JavaDoc x, int length) throws SQLException {
1056        throw getUnsupportedException();
1057    }
1058
1059    /** INTERNAL */
1060    public void updateBinaryStream(String JavaDoc columnName, InputStream JavaDoc x, int length) throws SQLException {
1061        throw getUnsupportedException();
1062    }
1063
1064    /** INTERNAL */
1065    public Reader JavaDoc getCharacterStream(String JavaDoc columnName) throws SQLException {
1066        throw getUnsupportedException();
1067    }
1068
1069    /** INTERNAL */
1070    public void updateCharacterStream(String JavaDoc columnName, Reader JavaDoc reader, int length) throws SQLException {
1071        throw getUnsupportedException();
1072    }
1073
1074    /** INTERNAL */
1075    public void updateObject(String JavaDoc columnName, Object JavaDoc x) throws SQLException {
1076        throw getUnsupportedException();
1077    }
1078
1079    /** INTERNAL */
1080    public void updateObject(String JavaDoc columnName, Object JavaDoc x, int scale) throws SQLException {
1081        throw getUnsupportedException();
1082    }
1083
1084    /** INTERNAL */
1085    public Object JavaDoc getObject(int i, Map JavaDoc map) throws SQLException {
1086        throw getUnsupportedException();
1087    }
1088
1089    /** INTERNAL */
1090    public void updateString(String JavaDoc columnName, String JavaDoc x) throws SQLException {
1091        throw getUnsupportedException();
1092    }
1093
1094    /** @deprecated INTERNAL */
1095    public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName, int scale) throws SQLException {
1096        throw getUnsupportedException();
1097    }
1098
1099    /** INTERNAL */
1100    public void updateBigDecimal(String JavaDoc columnName, BigDecimal JavaDoc x) throws SQLException {
1101        throw getUnsupportedException();
1102    }
1103
1104    /** INTERNAL */
1105    public URL JavaDoc getURL(String JavaDoc columnName) throws SQLException {
1106        throw getUnsupportedException();
1107    }
1108
1109    /** INTERNAL */
1110    public Array getArray(String JavaDoc colName) throws SQLException {
1111        throw getUnsupportedException();
1112    }
1113
1114    /** INTERNAL */
1115    public void updateArray(String JavaDoc columnName, Array x) throws SQLException {
1116        throw getUnsupportedException();
1117    }
1118
1119    /** INTERNAL */
1120    public Blob getBlob(String JavaDoc colName) throws SQLException {
1121        throw getUnsupportedException();
1122    }
1123
1124    /** INTERNAL */
1125    public void updateBlob(String JavaDoc columnName, Blob x) throws SQLException {
1126        throw getUnsupportedException();
1127    }
1128
1129    /** INTERNAL */
1130    public Clob getClob(String JavaDoc colName) throws SQLException {
1131        throw getUnsupportedException();
1132    }
1133
1134    /** INTERNAL */
1135    public void updateClob(String JavaDoc columnName, Clob x) throws SQLException {
1136        throw getUnsupportedException();
1137    }
1138
1139    /** INTERNAL */
1140    public void updateDate(String JavaDoc columnName, Date x) throws SQLException {
1141        throw getUnsupportedException();
1142    }
1143
1144    /** INTERNAL */
1145    public Date getDate(int columnIndex, Calendar JavaDoc cal) throws SQLException {
1146        throw getUnsupportedException();
1147    }
1148
1149    /** INTERNAL */
1150    public Ref getRef(String JavaDoc colName) throws SQLException {
1151        throw getUnsupportedException();
1152    }
1153
1154    /** INTERNAL */
1155    public void updateRef(String JavaDoc columnName, Ref x) throws SQLException {
1156        throw getUnsupportedException();
1157    }
1158
1159    /** INTERNAL */
1160    public void updateTime(String JavaDoc columnName, Time x) throws SQLException {
1161        throw getUnsupportedException();
1162    }
1163
1164    /** INTERNAL */
1165    public Time getTime(int columnIndex, Calendar JavaDoc cal) throws SQLException {
1166        throw getUnsupportedException();
1167    }
1168
1169    /** INTERNAL */
1170    public void updateTimestamp(String JavaDoc columnName, Timestamp x) throws SQLException {
1171        throw getUnsupportedException();
1172    }
1173
1174    /** INTERNAL */
1175    public Timestamp getTimestamp(int columnIndex, Calendar JavaDoc cal) throws SQLException {
1176        throw getUnsupportedException();
1177    }
1178
1179    /** INTERNAL */
1180    public Object JavaDoc getObject(String JavaDoc colName, Map JavaDoc map) throws SQLException {
1181        throw getUnsupportedException();
1182    }
1183
1184    /** INTERNAL */
1185    public Date getDate(String JavaDoc columnName, Calendar JavaDoc cal) throws SQLException {
1186        throw getUnsupportedException();
1187    }
1188
1189    /** INTERNAL */
1190    public Time getTime(String JavaDoc columnName, Calendar JavaDoc cal) throws SQLException {
1191        throw getUnsupportedException();
1192    }
1193
1194    /** INTERNAL */
1195    public Timestamp getTimestamp(String JavaDoc columnName, Calendar JavaDoc cal) throws SQLException {
1196        throw getUnsupportedException();
1197    }
1198
1199    // --- private -----------------------------
1200

1201    private SQLException getUnsupportedException() {
1202        return new SQLException("Feature not supported", "HYC00");
1203    }
1204
1205    private Object JavaDoc get(String JavaDoc columnName) throws SQLException {
1206        return get(findColumn(columnName));
1207    }
1208
1209    private void checkColumnIndex(int columnIndex) throws SQLException {
1210        if (columnIndex < 0 || columnIndex >= columns.size()) {
1211            throw new SQLException("Invalid column index " + (columnIndex + 1), "90009");
1212        }
1213    }
1214
1215    private Object JavaDoc get(int columnIndex) throws SQLException {
1216        if (currentRow == null) {
1217            throw new SQLException("No data is available", "02000");
1218        }
1219        columnIndex--;
1220        checkColumnIndex(columnIndex);
1221        Object JavaDoc o = columnIndex < currentRow.length ? currentRow[columnIndex] : null;
1222        wasNull = o == null;
1223        return o;
1224    }
1225
1226    private Column getColumn(int i) throws SQLException {
1227        checkColumnIndex(i);
1228        return (Column) columns.get(i);
1229    }
1230
1231    //#ifdef JDK16
1232
/*
1233    public RowId getRowId(int columnIndex) throws SQLException {
1234        throw getUnsupportedException();
1235    }
1236*/

1237    //#endif
1238

1239    //#ifdef JDK16
1240
/*
1241    public RowId getRowId(String columnName) throws SQLException {
1242        throw getUnsupportedException();
1243    }
1244*/

1245    //#endif
1246

1247    /** INTERNAL */
1248    //#ifdef JDK16
1249
/*
1250    public void updateRowId(int columnIndex, RowId x) throws SQLException {
1251        throw getUnsupportedException();
1252    }
1253*/

1254    //#endif
1255

1256    /** INTERNAL */
1257//#ifdef JDK16
1258
/*
1259    public void updateRowId(String columnName, RowId x) throws SQLException {
1260        throw getUnsupportedException();
1261    }
1262*/

1263//#endif
1264

1265    /**
1266     * Returns the current result set holdability.
1267     *
1268     * @return the holdability
1269     */

1270//#ifdef JDK14
1271
public int getHoldability() {
1272        return ResultSet.HOLD_CURSORS_OVER_COMMIT;
1273    }
1274//#endif
1275

1276    /**
1277     * Returns whether this result set has been closed.
1278     *
1279     * @return true if the result set was closed
1280     */

1281    public boolean isClosed() throws SQLException {
1282        return rows == null;
1283    }
1284
1285    /** INTERNAL */
1286    public void updateNString(int columnIndex, String JavaDoc nString) throws SQLException {
1287        throw getUnsupportedException();
1288    }
1289
1290    /** INTERNAL */
1291    public void updateNString(String JavaDoc columnName, String JavaDoc nString) throws SQLException {
1292        throw getUnsupportedException();
1293    }
1294
1295    /** INTERNAL */
1296    //#ifdef JDK16
1297
/*
1298    public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
1299        throw getUnsupportedException();
1300    }
1301*/

1302    //#endif
1303

1304    /** INTERNAL */
1305    //#ifdef JDK16
1306
/*
1307    public void updateNClob(String columnName, NClob nClob) throws SQLException {
1308        throw getUnsupportedException();
1309    }
1310*/

1311    //#endif
1312

1313    /** INTERNAL */
1314    //#ifdef JDK16
1315
/*
1316    public NClob getNClob(int columnIndex) throws SQLException {
1317        throw getUnsupportedException();
1318    }
1319*/

1320    //#endif
1321

1322    /** INTERNAL */
1323    //#ifdef JDK16
1324
/*
1325    public NClob getNClob(String columnName) throws SQLException {
1326        throw getUnsupportedException();
1327    }
1328*/

1329    //#endif
1330

1331    /** INTERNAL */
1332    //#ifdef JDK16
1333
/*
1334    public SQLXML getSQLXML(int columnIndex) throws SQLException {
1335        throw getUnsupportedException();
1336    }
1337*/

1338    //#endif
1339

1340    /** INTERNAL */
1341    //#ifdef JDK16
1342
/*
1343    public SQLXML getSQLXML(String columnName) throws SQLException {
1344        throw getUnsupportedException();
1345    }
1346*/

1347    //#endif
1348

1349    /** INTERNAL */
1350    //#ifdef JDK16
1351
/*
1352    public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
1353        throw getUnsupportedException();
1354    }
1355*/

1356    //#endif
1357

1358    /** INTERNAL */
1359    //#ifdef JDK16
1360
/*
1361    public void updateSQLXML(String columnName, SQLXML xmlObject) throws SQLException {
1362        throw getUnsupportedException();
1363    }
1364*/

1365    //#endif
1366

1367    /** INTERNAL */
1368    public String JavaDoc getNString(int columnIndex) throws SQLException {
1369        return getString(columnIndex);
1370    }
1371
1372    /** INTERNAL */
1373    public String JavaDoc getNString(String JavaDoc columnName) throws SQLException {
1374        return getString(columnName);
1375    }
1376
1377    /** INTERNAL */
1378    public Reader JavaDoc getNCharacterStream(int columnIndex) throws SQLException {
1379        throw getUnsupportedException();
1380    }
1381
1382    /** INTERNAL */
1383    public Reader JavaDoc getNCharacterStream(String JavaDoc columnName) throws SQLException {
1384        throw getUnsupportedException();
1385    }
1386
1387    /** INTERNAL */
1388    public void updateNCharacterStream(int columnIndex, Reader JavaDoc x, int length) throws SQLException {
1389        throw getUnsupportedException();
1390    }
1391
1392    /** INTERNAL */
1393    public void updateNCharacterStream(String JavaDoc columnName, Reader JavaDoc x, int length) throws SQLException {
1394        throw getUnsupportedException();
1395    }
1396
1397    /** INTERNAL */
1398    //#ifdef JDK16
1399
/*
1400    public <T> T unwrap(Class<T> iface) throws SQLException {
1401        throw getUnsupportedException();
1402    }
1403*/

1404    //#endif
1405

1406    /** INTERNAL */
1407    //#ifdef JDK16
1408
/*
1409    public boolean isWrapperFor(Class<?> iface) throws SQLException {
1410        throw getUnsupportedException();
1411    }
1412*/

1413    //#endif
1414

1415    /** INTERNAL */
1416    public void updateAsciiStream(int columnIndex, InputStream JavaDoc x) throws SQLException {
1417        throw getUnsupportedException();
1418    }
1419
1420    /** INTERNAL */
1421    public void updateAsciiStream(String JavaDoc columnName, InputStream JavaDoc x) throws SQLException {
1422        throw getUnsupportedException();
1423    }
1424
1425    /** INTERNAL */
1426    public void updateAsciiStream(int columnIndex, InputStream JavaDoc x, long length) throws SQLException {
1427        throw getUnsupportedException();
1428    }
1429
1430    /** INTERNAL */
1431    public void updateAsciiStream(String JavaDoc columnName, InputStream JavaDoc x, long length) throws SQLException {
1432        throw getUnsupportedException();
1433    }
1434
1435    /** INTERNAL */
1436    public void updateBinaryStream(int columnName, InputStream JavaDoc x) throws SQLException {
1437        throw getUnsupportedException();
1438    }
1439
1440    /** INTERNAL */
1441    public void updateBinaryStream(String JavaDoc columnName, InputStream JavaDoc x) throws SQLException {
1442        throw getUnsupportedException();
1443    }
1444
1445    /** INTERNAL */
1446    public void updateBinaryStream(int columnIndex, InputStream JavaDoc x, long length) throws SQLException {
1447        throw getUnsupportedException();
1448    }
1449
1450    /** INTERNAL */
1451    public void updateBinaryStream(String JavaDoc columnName, InputStream JavaDoc x, long length) throws SQLException {
1452        throw getUnsupportedException();
1453    }
1454
1455    /** INTERNAL */
1456    public void updateBlob(int columnIndex, InputStream JavaDoc x) throws SQLException {
1457        throw getUnsupportedException();
1458    }
1459
1460    /** INTERNAL */
1461    public void updateBlob(String JavaDoc columnName, InputStream JavaDoc x) throws SQLException {
1462        throw getUnsupportedException();
1463    }
1464
1465    /** INTERNAL */
1466    public void updateBlob(int columnIndex, InputStream JavaDoc x, long length) throws SQLException {
1467        throw getUnsupportedException();
1468    }
1469
1470    /** INTERNAL */
1471    public void updateBlob(String JavaDoc columnName, InputStream JavaDoc x, long length) throws SQLException {
1472        throw getUnsupportedException();
1473    }
1474
1475    /** INTERNAL */
1476    public void updateCharacterStream(int columnIndex, Reader JavaDoc x) throws SQLException {
1477        throw getUnsupportedException();
1478    }
1479
1480    /** INTERNAL */
1481    public void updateCharacterStream(String JavaDoc columnName, Reader JavaDoc x) throws SQLException {
1482        throw getUnsupportedException();
1483    }
1484
1485    /** INTERNAL */
1486    public void updateCharacterStream(int columnIndex, Reader JavaDoc x, long length) throws SQLException {
1487        throw getUnsupportedException();
1488    }
1489
1490    /** INTERNAL */
1491    public void updateCharacterStream(String JavaDoc columnName, Reader JavaDoc x, long length) throws SQLException {
1492        throw getUnsupportedException();
1493    }
1494
1495    /** INTERNAL */
1496    public void updateClob(int columnIndex, Reader JavaDoc x) throws SQLException {
1497        throw getUnsupportedException();
1498    }
1499
1500    /** INTERNAL */
1501    public void updateClob(String JavaDoc columnName, Reader JavaDoc x) throws SQLException {
1502        throw getUnsupportedException();
1503    }
1504
1505    /** INTERNAL */
1506    public void updateClob(int columnIndex, Reader JavaDoc x, long length) throws SQLException {
1507        throw getUnsupportedException();
1508    }
1509
1510    /** INTERNAL */
1511    public void updateClob(String JavaDoc columnName, Reader JavaDoc x, long length) throws SQLException {
1512        throw getUnsupportedException();
1513    }
1514
1515    /** INTERNAL */
1516    public void updateNCharacterStream(int columnIndex, Reader JavaDoc x) throws SQLException {
1517        throw getUnsupportedException();
1518    }
1519
1520    /** INTERNAL */
1521    public void updateNCharacterStream(String JavaDoc columnName, Reader JavaDoc x) throws SQLException {
1522        throw getUnsupportedException();
1523    }
1524
1525    /** INTERNAL */
1526    public void updateNCharacterStream(int columnIndex, Reader JavaDoc x, long length) throws SQLException {
1527        throw getUnsupportedException();
1528    }
1529
1530    /** INTERNAL */
1531    public void updateNCharacterStream(String JavaDoc columnName, Reader JavaDoc x, long length) throws SQLException {
1532        throw getUnsupportedException();
1533    }
1534
1535    /** INTERNAL */
1536    public void updateNClob(int columnIndex, Reader JavaDoc x) throws SQLException {
1537        throw getUnsupportedException();
1538    }
1539
1540    /** INTERNAL */
1541    public void updateNClob(String JavaDoc columnName, Reader JavaDoc x) throws SQLException {
1542        throw getUnsupportedException();
1543    }
1544
1545    /** INTERNAL */
1546    public void updateNClob(int columnIndex, Reader JavaDoc x, long length) throws SQLException {
1547        throw getUnsupportedException();
1548    }
1549
1550    /** INTERNAL */
1551    public void updateNClob(String JavaDoc columnName, Reader JavaDoc x, long length) throws SQLException {
1552        throw getUnsupportedException();
1553    }
1554
1555}
1556
Popular Tags