KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > i18njdbc > I18nResultSet


1 /**
2     Copyright (C) 2002-2003 Together
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Lesser General Public
6     License as published by the Free Software Foundation; either
7     version 2.1 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     Lesser General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public
15     License along with this library; if not, write to the Free Software
16     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 */

19
20 package org.webdocwf.util.i18njdbc;
21
22 import java.io.ByteArrayInputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24 import java.io.InputStream JavaDoc;
25 import java.io.Reader JavaDoc;
26 import java.io.StringReader JavaDoc;
27 import java.math.BigDecimal JavaDoc;
28 import java.net.URL JavaDoc;
29 import java.sql.*;
30 import java.util.Calendar JavaDoc;
31 import java.util.Enumeration JavaDoc;
32 import java.util.Map JavaDoc;
33
34 /**
35  * This class implements the ResultSet interface for the I18nJdbc driver.
36  *
37  * @author Zoran Milakovic
38  * @author Zeljko Kovacevic
39  */

40 public class I18nResultSet implements ResultSet {
41
42     /** Metadata for this ResultSet */
43     protected ResultSetMetaData resultSetMetaData;
44
45     /**Properties */
46     protected I18nProperties properties;
47
48     /** Table referenced by the Statement */
49     protected String JavaDoc tableName;
50
51     /** Array of available columns for referenced table */
52     protected String JavaDoc[] columnNames;
53
54     protected String JavaDoc[] columnTypes;
55
56     protected String JavaDoc[] whereColumnNames;
57
58     protected String JavaDoc[] whereColumnValues;
59
60     /** Last column name index read */
61     protected int lastIndexRead = -1;
62
63     /** InputStream to keep track of */
64     protected InputStream JavaDoc is;
65
66     protected Enumeration JavaDoc en;
67
68     private String JavaDoc currKey = "";
69
70     protected I18nConnection connection;
71
72
73     /**
74      * Constructor for the I18nResultSet object
75      *
76      * @param statement I18nStatement that produced this ResultSet
77      * @param tableName Table referenced by the Statement
78      * @param columnNames Array of available columns for referenced table
79      * @param columnWhereNames Array of column names in where clause
80      * @param columnWhereValues Array of values in where clause
81      */

82     protected I18nResultSet(I18nStatement statement,
83                                                     String JavaDoc tableName,
84                                                     String JavaDoc[] columnNames,
85                                                     String JavaDoc[] columnWhereNames,
86                                                     String JavaDoc[] columnWhereValues) throws SQLException {
87
88         try {
89             this.connection = (I18nConnection) statement.getConnection();
90         } catch (SQLException e) {
91             throw e;
92         }
93         this.tableName = tableName;
94         this.columnNames = columnNames;
95         this.whereColumnNames = columnWhereNames;
96         this.whereColumnValues = columnWhereValues;
97         this.properties = statement.getProperties();
98         this.en = statement.getProperties().keys();
99
100         if (columnNames[0].equals("*")) {
101             this.columnNames = this.connection.getColumnNames();
102         }
103     }
104     /**
105         * Constructor for the I18nResultSet object
106         *
107         * @param statement I18nPreparedStatement that produced this ResultSet
108         * @param tableName Table referenced by the Statement
109         * @param columnNames Array of available columns for referenced table
110         * @param columnWhereNames Array of column names in where clause
111         * @param columnWhereValues Array of values in where clause
112         */

113     protected I18nResultSet(I18nPreparedStatement statement,
114                                                     String JavaDoc tableName,
115                                                     String JavaDoc[] columnNames,
116                                                     String JavaDoc[] columnWhereNames,
117                                                     String JavaDoc[] columnWhereValues) throws SQLException {
118         try {
119             this.connection = (I18nConnection) statement.getConnection();
120         } catch (SQLException e) {
121             throw e;
122         }
123         this.tableName = tableName;
124         this.columnNames = columnNames;
125         this.whereColumnNames = columnWhereNames;
126         this.whereColumnValues = columnWhereValues;
127         this.properties = statement.getProperties();
128         this.en = statement.getProperties().keys();
129
130         if (columnNames[0].equals("*")) {
131             this.columnNames = this.connection.getColumnNames();
132         }
133     }
134     /**
135      * Moves the cursor down one row from its current position.
136      * A <code>ResultSet</code> cursor is initially positioned
137      * before the first row; the first call to the method
138      * <code>next</code> makes the first row the current row; the
139      * second call makes the second row the current row, and so on.
140      *
141      * <P>If an input stream is open for the current row, a call
142      * to the method <code>next</code> will
143      * implicitly close it. A <code>ResultSet</code> object's
144      * warning chain is cleared when a new row is read.
145      *
146      * @return <code>true</code> if the new current row is valid;
147      * <code>false</code> if there are no more rows
148      * @exception SQLException if a database access error occurs
149      */

150     public boolean next() throws SQLException {
151
152         boolean retVal = false;
153         mainLoop : while (en.hasMoreElements()) {
154             this.currKey = en.nextElement().toString();
155             retVal = true;
156             out : for (int i = 0; i < this.whereColumnNames.length; i++) {
157                 if (whereColumnValues[i] == null || whereColumnValues[i].equals("null"))
158                     whereColumnValues[i] = "";
159                 if (this.whereColumnNames[i].equalsIgnoreCase(this.connection.getNameColumn())) {
160                     if (!this.currKey.equals(this.whereColumnValues[i])) {
161                         retVal = false;
162                         break out;
163                     }
164                 } else if (this.whereColumnNames[i].equalsIgnoreCase(this.connection.getValueColumn())) {
165                     if (!(properties.getProperty(this.currKey).equals(this.whereColumnValues[i]))) {
166                         retVal = false;
167                         break out;
168                     }
169                 }
170             }
171             if (retVal == true)
172                 return true;
173         }
174         return false;
175     }
176
177     /**
178      * Releases this <code>ResultSet</code> object's database and
179      * JDBC resources immediately instead of waiting for
180      * this to happen when it is automatically closed.
181      *
182      *
183      * <P><B>Note:</B> A <code>ResultSet</code> object
184      * is automatically closed by the
185      * <code>Statement</code> object that generated it when
186      * that <code>Statement</code> object is closed,
187      * re-executed, or is used to retrieve the next result from a
188      * sequence of multiple results. A <code>ResultSet</code> object
189      * is also automatically closed when it is garbage collected.
190      *
191      * @exception SQLException if a database access error occurs
192      */

193     public void close() throws SQLException {
194         // reader.close();
195
}
196
197     /**
198      * Reports whether
199      * the last column read had a value of SQL <code>NULL</code>.
200      * Note that you must first call one of the getter methods
201      * on a column to try to read its value and then call
202      * the method <code>wasNull</code> to see if the value read was
203      * SQL <code>NULL</code>.
204      *
205      * @return <code>true</code> if the last column value read was SQL
206      * <code>NULL</code> and <code>false</code> otherwise
207      * @exception SQLException if a database access error occurs
208      */

209     public boolean wasNull() throws SQLException {
210         if (lastIndexRead >= 0) {
211             return getString(lastIndexRead) == null;
212         } else {
213             throw new SQLException("No previous getter method called");
214         }
215     }
216
217     //======================================================================
218
// Methods for accessing results by column index
219
//======================================================================
220

221     /**
222      * Retrieves the value of the designated column in the current row
223      * of this <code>ResultSet</code> object as
224      * a <code>String</code> in the Java programming language.
225      *
226      * @param columnIndex the first column is 1, the second is 2, ...
227      * @return the column value; if the value is SQL <code>NULL</code>, the
228      * value returned is <code>null</code>
229      * @exception SQLException if a database access error occurs
230      */

231     public String JavaDoc getString(int columnIndex) throws SQLException {
232         // perform pre-accessor method processing
233
String JavaDoc retValue = "";
234         preAccessor(columnIndex);
235         if (columnIndex < 1 || columnIndex > columnNames.length) {
236             throw new SQLException("Column not found: invalid index: " + columnIndex);
237         } else if (columnIndex >= 1) {
238             // I18nConnection conn = (I18nConnection)this.statement.getConnection();
239
String JavaDoc colName = this.connection.getNameColumn();
240             String JavaDoc colValue = this.connection.getValueColumn();
241             String JavaDoc column = columnNames[columnIndex - 1];
242             if (column.equalsIgnoreCase(colName)) {
243                 retValue = this.currKey;
244             } else if (column.equalsIgnoreCase(colValue)) {
245                 retValue = properties.getProperty(this.currKey);
246             }
247
248         }
249         return retValue;
250
251     }
252
253     /**
254      * Retrieves the value of the designated column in the current row
255      * of this <code>ResultSet</code> object as
256      * a <code>boolean</code> in the Java programming language.
257      *
258      * @param columnIndex the first column is 1, the second is 2, ...
259      * @return the column value; if the value is SQL <code>NULL</code>, the
260      * value returned is <code>false</code>
261      * @exception SQLException if a database access error occurs
262      */

263     public boolean getBoolean(int columnIndex) throws SQLException {
264         String JavaDoc str = getString(columnIndex);
265         return (str == null) ? false : Boolean.valueOf(str).booleanValue();
266     }
267
268     /**
269      * Retrieves the value of the designated column in the current row
270      * of this <code>ResultSet</code> object as
271      * a <code>byte</code> in the Java programming language.
272      *
273      * @param columnIndex the first column is 1, the second is 2, ...
274      * @return the column value; if the value is SQL <code>NULL</code>, the
275      * value returned is <code>0</code>
276      * @exception SQLException if a database access error occurs
277      */

278     public byte getByte(int columnIndex) throws SQLException {
279         String JavaDoc str = getString(columnIndex);
280         return (str == null) ? 0 : Byte.parseByte(str);
281     }
282
283     /**
284      * Retrieves the value of the designated column in the current row
285      * of this <code>ResultSet</code> object as
286      * a <code>short</code> in the Java programming language.
287      *
288      * @param columnIndex the first column is 1, the second is 2, ...
289      * @return the column value; if the value is SQL <code>NULL</code>, the
290      * value returned is <code>0</code>
291      * @exception SQLException if a database access error occurs
292      */

293     public short getShort(int columnIndex) throws SQLException {
294         String JavaDoc str = getString(columnIndex);
295         return (str == null) ? 0 : Short.parseShort(str);
296     }
297
298     /**
299      * Gets the value of the designated column in the current row
300      * of this <code>ResultSet</code> object as
301      * an <code>int</code> in the Java programming language.
302      *
303      * @param columnIndex the first column is 1, the second is 2, ...
304      * @return the column value; if the value is SQL <code>NULL</code>, the
305      * value returned is <code>0</code>
306      * @exception SQLException if a database access error occurs
307      */

308     public int getInt(int columnIndex) throws SQLException {
309         String JavaDoc str = getString(columnIndex);
310         return (str == null) ? 0 : Integer.parseInt(str);
311     }
312
313     /**
314      * Retrieves the value of the designated column in the current row
315      * of this <code>ResultSet</code> object as
316      * a <code>long</code> in the Java programming language.
317      *
318      * @param columnIndex the first column is 1, the second is 2, ...
319      * @return the column value; if the value is SQL <code>NULL</code>, the
320      * value returned is <code>0</code>
321      * @exception SQLException if a database access error occurs
322      */

323     public long getLong(int columnIndex) throws SQLException {
324         String JavaDoc str = getString(columnIndex);
325         return (str == null) ? 0L : Long.parseLong(str);
326     }
327
328     /**
329      * Gets the value of the designated column in the current row
330      * of this <code>ResultSet</code> object as
331      * a <code>float</code> in the Java programming language.
332      *
333      * @param columnIndex the first column is 1, the second is 2, ...
334      * @return the column value; if the value is SQL <code>NULL</code>, the
335      * value returned is <code>0</code>
336      * @exception SQLException if a database access error occurs
337      */

338     public float getFloat(int columnIndex) throws SQLException {
339         String JavaDoc str = getString(columnIndex);
340         return (str == null) ? 0F : Float.parseFloat(str);
341     }
342
343     /**
344      * Retrieves the value of the designated column in the current row
345      * of this <code>ResultSet</code> object as
346      * a <code>double</code> in the Java programming language.
347      *
348      * @param columnIndex the first column is 1, the second is 2, ...
349      * @return the column value; if the value is SQL <code>NULL</code>, the
350      * value returned is <code>0</code>
351      * @exception SQLException if a database access error occurs
352      */

353     public double getDouble(int columnIndex) throws SQLException {
354         String JavaDoc str = getString(columnIndex);
355         return (str == null) ? 0D : Double.parseDouble(str);
356     }
357
358     /**
359      * Retrieves the value of the designated column in the current row
360      * of this <code>ResultSet</code> object as
361      * a <code>java.sql.BigDecimal</code> in the Java programming language.
362      *
363      * @param columnIndex the first column is 1, the second is 2, ...
364      * @param scale the number of digits to the right of the decimal point
365      * @return the column value; if the value is SQL <code>NULL</code>, the
366      * value returned is <code>null</code>
367      * @exception SQLException if a database access error occurs
368      * @deprecated
369      */

370     public BigDecimal JavaDoc getBigDecimal(int columnIndex, int scale) throws SQLException {
371         // let getBigDecimal(int) handle this for now
372
return getBigDecimal(columnIndex);
373     }
374
375     /**
376      * Retrieves the value of the designated column in the current row
377      * of this <code>ResultSet</code> object as
378      * a <code>byte</code> array in the Java programming language.
379      * The bytes represent the raw values returned by the driver.
380      *
381      * @param columnIndex the first column is 1, the second is 2, ...
382      * @return the column value; if the value is SQL <code>NULL</code>, the
383      * value returned is <code>null</code>
384      * @exception SQLException if a database access error occurs
385      */

386     public byte[] getBytes(int columnIndex) throws SQLException {
387         String JavaDoc str = getString(columnIndex);
388         return (str == null || str.equals("")) ? null : Utils.hexStringToBytes(str);
389     }
390
391     /**
392      * Retrieves the value of the designated column in the current row
393      * of this <code>ResultSet</code> object as
394      * a <code>java.sql.Date</code> object in the Java programming language.
395      *
396      * @param columnIndex the first column is 1, the second is 2, ...
397      * @return the column value; if the value is SQL <code>NULL</code>, the
398      * value returned is <code>null</code>
399      * @exception SQLException if a database access error occurs
400      */

401     public Date getDate(int columnIndex) throws SQLException {
402         String JavaDoc str = getString(columnIndex);
403         return (str == null) ? null : Date.valueOf(str);
404     }
405
406     /**
407      * Retrieves the value of the designated column in the current row
408      * of this <code>ResultSet</code> object as
409      * a <code>java.sql.Time</code> object in the Java programming language.
410      *
411      * @param columnIndex the first column is 1, the second is 2, ...
412      * @return the column value; if the value is SQL <code>NULL</code>, the
413      * value returned is <code>null</code>
414      * @exception SQLException if a database access error occurs
415      */

416     public Time getTime(int columnIndex) throws SQLException {
417         String JavaDoc str = getString(columnIndex);
418         return (str == null) ? null : Time.valueOf(str);
419     }
420
421     /**
422      * Retrieves the value of the designated column in the current row
423      * of this <code>ResultSet</code> object as a
424      * <code>java.sql.Timestamp</code> object in the Java programming language.
425      *
426      * @param columnIndex the first column is 1, the second is 2, ...
427      * @return the column value; if the value is SQL <code>NULL</code>, the
428      * value returned is <code>null</code>
429      * @exception SQLException if a database access error occurs
430      */

431     public Timestamp getTimestamp(int columnIndex) throws SQLException {
432         String JavaDoc str = getString(columnIndex);
433         return (str == null) ? null : Timestamp.valueOf(str);
434     }
435
436     /**
437      * Retrieves the value of the designated column in the current row
438      * of this <code>ResultSet</code> object as a stream of ASCII characters.
439      * The value can then be read in chunks from the stream. This method is
440      * particularly suitable for retrieving large <char>LONGVARCHAR</char>
441      * values. The JDBC driver will do any necessary conversion from the
442      * database format into ASCII.
443      *
444      * <P><B>Note:</B> All the data in the returned stream must be
445      * read prior to getting the value of any other column. The next
446      * call to a getter method implicitly closes the stream. Also, a
447      * stream may return <code>0</code> when the method
448      * <code>InputStream.available</code>
449      * is called whether there is data available or not.
450      *
451      * @param columnIndex the first column is 1, the second is 2, ...
452      * @return a Java input stream that delivers the database column value
453      * as a stream of one-byte ASCII characters;
454      * if the value is SQL <code>NULL</code>, the
455      * value returned is <code>null</code>
456      * @exception SQLException if a database access error occurs
457      */

458     public InputStream JavaDoc getAsciiStream(int columnIndex) throws SQLException {
459         String JavaDoc str = getString(columnIndex);
460         is = new ByteArrayInputStream JavaDoc(str.getBytes());
461         return (str == null) ? null : is;
462     }
463
464     /**
465      * Retrieves the value of the designated column in the current row
466      * of this <code>ResultSet</code> object as
467      * as a stream of two-byte Unicode characters. The first byte is
468      * the high byte; the second byte is the low byte.
469      *
470      * The value can then be read in chunks from the
471      * stream. This method is particularly
472      * suitable for retrieving large <code>LONGVARCHAR</code>values. The
473      * JDBC driver will do any necessary conversion from the database
474      * format into Unicode.
475      *
476      * <P><B>Note:</B> All the data in the returned stream must be
477      * read prior to getting the value of any other column. The next
478      * call to a getter method implicitly closes the stream.
479      * Also, a stream may return <code>0</code> when the method
480      * <code>InputStream.available</code>
481      * is called, whether there is data available or not.
482      *
483      * @param columnIndex the first column is 1, the second is 2, ...
484      * @return a Java input stream that delivers the database column value
485      * as a stream of two-byte Unicode characters;
486      * if the value is SQL <code>NULL</code>, the value returned is
487      * <code>null</code>
488      *
489      * @exception SQLException if a database access error occurs
490      * @deprecated use <code>getCharacterStream</code> in place of
491      * <code>getUnicodeStream</code>
492      */

493     public InputStream JavaDoc getUnicodeStream(int columnIndex) throws SQLException {
494         // delegate to getAsciiStream(int)
495
return getAsciiStream(columnIndex);
496     }
497
498     /**
499      * Retrieves the value of the designated column in the current row
500      * of this <code>ResultSet</code> object as a binary stream of
501      * uninterpreted bytes. The value can then be read in chunks from the
502      * stream. This method is particularly
503      * suitable for retrieving large <code>LONGVARBINARY</code> values.
504      *
505      * <P><B>Note:</B> All the data in the returned stream must be
506      * read prior to getting the value of any other column. The next
507      * call to a getter method implicitly closes the stream. Also, a
508      * stream may return <code>0</code> when the method
509      * <code>InputStream.available</code>
510      * is called whether there is data available or not.
511      *
512      * @param columnIndex the first column is 1, the second is 2, ...
513      * @return a Java input stream that delivers the database column value
514      * as a stream of uninterpreted bytes;
515      * if the value is SQL <code>NULL</code>, the value returned is
516      * <code>null</code>
517      * @exception SQLException if a database access error occurs
518      */

519     public InputStream JavaDoc getBinaryStream(int columnIndex) throws SQLException {
520         // delegate to getAsciiStream(int)
521
return getAsciiStream(columnIndex);
522     }
523
524     //======================================================================
525
// Methods for accessing results by column name
526
//======================================================================
527

528     /**
529      * Retrieves the value of the designated column in the current row
530      * of this <code>ResultSet</code> object as
531      * a <code>String</code> in the Java programming language.
532      *
533      * @param columnName the SQL name of the column
534      * @return the column value; if the value is SQL <code>NULL</code>, the
535      * value returned is <code>null</code>
536      * @exception SQLException if a database access error occurs
537      */

538     public String JavaDoc getString(String JavaDoc columnName) throws SQLException {
539         // perform pre-accessor method processing
540
preAccessor(columnName);
541         String JavaDoc colName = this.connection.getNameColumn();
542         String JavaDoc colValue = this.connection.getValueColumn();
543         String JavaDoc retValue = "";
544         if (columnName.equalsIgnoreCase(colName)) {
545             retValue = this.currKey;
546         } else if (columnName.equalsIgnoreCase(colValue)) {
547             retValue = properties.getProperty(this.currKey);
548         }
549         return retValue;
550     }
551
552     /**
553      * Retrieves the value of the designated column in the current row
554      * of this <code>ResultSet</code> object as
555      * a <code>boolean</code> in the Java programming language.
556      *
557      * @param columnName the SQL name of the column
558      * @return the column value; if the value is SQL <code>NULL</code>, the
559      * value returned is <code>false</code>
560      * @exception SQLException if a database access error occurs
561      */

562     public boolean getBoolean(String JavaDoc columnName) throws SQLException {
563         String JavaDoc str = getString(columnName);
564         return (str == null) ? false : Boolean.valueOf(str).booleanValue();
565     }
566
567     /**
568      * Retrieves the value of the designated column in the current row
569      * of this <code>ResultSet</code> object as
570      * a <code>byte</code> in the Java programming language.
571      *
572      * @param columnName the SQL name of the column
573      * @return the column value; if the value is SQL <code>NULL</code>, the
574      * value returned is <code>0</code>
575      * @exception SQLException if a database access error occurs
576      */

577     public byte getByte(String JavaDoc columnName) throws SQLException {
578         String JavaDoc str = getString(columnName);
579         return (str == null) ? 0 : Byte.parseByte(str);
580     }
581
582     /**
583      * Retrieves the value of the designated column in the current row
584      * of this <code>ResultSet</code> object as
585      * a <code>short</code> in the Java programming language.
586      *
587      * @param columnName the SQL name of the column
588      * @return the column value; if the value is SQL <code>NULL</code>, the
589      * value returned is <code>0</code>
590      * @exception SQLException if a database access error occurs
591      */

592     public short getShort(String JavaDoc columnName) throws SQLException {
593         String JavaDoc str = getString(columnName);
594         return (str == null) ? 0 : Short.parseShort(str);
595     }
596
597     /**
598      * Gets the value of the designated column in the current row
599      * of this <code>ResultSet</code> object as
600      * an <code>int</code> in the Java programming language.
601      *
602      * @param columnName the SQL name of the column
603      * @return the column value; if the value is SQL <code>NULL</code>, the
604      * value returned is <code>0</code>
605      * @exception SQLException if a database access error occurs
606      */

607     public int getInt(String JavaDoc columnName) throws SQLException {
608         String JavaDoc str = getString(columnName);
609         return (str == null) ? 0 : Integer.parseInt(str);
610     }
611
612     /**
613      * Retrieves the value of the designated column in the current row
614      * of this <code>ResultSet</code> object as
615      * a <code>long</code> in the Java programming language.
616      *
617      * @param columnName the SQL name of the column
618      * @return the column value; if the value is SQL <code>NULL</code>, the
619      * value returned is <code>0</code>
620      * @exception SQLException if a database access error occurs
621      */

622     public long getLong(String JavaDoc columnName) throws SQLException {
623         String JavaDoc str = getString(columnName);
624         return (str == null) ? 0L : Long.parseLong(str);
625     }
626
627     /**
628      * Gets the value of the designated column in the current row
629      * of this <code>ResultSet</code> object as
630      * a <code>float</code> in the Java programming language.
631      *
632      * @param columnName the SQL name of the column
633      * @return the column value; if the value is SQL <code>NULL</code>, the
634      * value returned is <code>0</code>
635      * @exception SQLException if a database access error occurs
636      */

637     public float getFloat(String JavaDoc columnName) throws SQLException {
638         String JavaDoc str = getString(columnName);
639         return (str == null) ? 0F : Float.parseFloat(str);
640     }
641
642     /**
643      * Retrieves the value of the designated column in the current row
644      * of this <code>ResultSet</code> object as
645      * a <code>double</code> in the Java programming language.
646      *
647      * @param columnName the SQL name of the column
648      * @return the column value; if the value is SQL <code>NULL</code>, the
649      * value returned is <code>0</code>
650      * @exception SQLException if a database access error occurs
651      */

652     public double getDouble(String JavaDoc columnName) throws SQLException {
653         String JavaDoc str = getString(columnName);
654         return (str == null) ? 0D : Double.parseDouble(str);
655     }
656
657     /**
658      * Retrieves the value of the designated column in the current row
659      * of this <code>ResultSet</code> object as
660      * a <code>java.math.BigDecimal</code> in the Java programming language.
661      *
662      * @param columnName the SQL name of the column
663      * @param scale the number of digits to the right of the decimal point
664      * @return the column value; if the value is SQL <code>NULL</code>, the
665      * value returned is <code>null</code>
666      * @exception SQLException if a database access error occurs
667      * @deprecated
668      */

669     public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName, int scale) throws SQLException {
670         // let getBigDecimal(String) handle this for now
671
return getBigDecimal(columnName);
672     }
673
674     /**
675      * Retrieves the value of the designated column in the current row
676      * of this <code>ResultSet</code> object as
677      * a <code>byte</code> array in the Java programming language.
678      * The bytes represent the raw values returned by the driver.
679      *
680      * @param columnName the SQL name of the column
681      * @return the column value; if the value is SQL <code>NULL</code>, the
682      * value returned is <code>null</code>
683      * @exception SQLException if a database access error occurs
684      */

685     public byte[] getBytes(String JavaDoc columnName) throws SQLException {
686         String JavaDoc str = getString(columnName);
687         return (str == null) ? null : Utils.hexStringToBytes(str);
688     }
689
690     /**
691      * Retrieves the value of the designated column in the current row
692      * of this <code>ResultSet</code> object as
693      * a <code>java.sql.Date</code> object in the Java programming language.
694      *
695      * @param columnName the SQL name of the column
696      * @return the column value; if the value is SQL <code>NULL</code>, the
697      * value returned is <code>null</code>
698      * @exception SQLException if a database access error occurs
699      */

700     public Date getDate(String JavaDoc columnName) throws SQLException {
701         String JavaDoc str = getString(columnName);
702         return (str == null) ? null : Date.valueOf(str);
703     }
704
705     /**
706      * Retrieves the value of the designated column in the current row
707      * of this <code>ResultSet</code> object as
708      * a <code>java.sql.Time</code> object in the Java programming language.
709      *
710      * @param columnName the SQL name of the column
711      * @return the column value;
712      * if the value is SQL <code>NULL</code>,
713      * the value returned is <code>null</code>
714      * @exception SQLException if a database access error occurs
715      */

716     public Time getTime(String JavaDoc columnName) throws SQLException {
717         String JavaDoc str = getString(columnName);
718         return (str == null) ? null : Time.valueOf(str);
719     }
720
721     /**
722      * Retrieves the value of the designated column in the current row
723      * of this <code>ResultSet</code> object as
724      * a <code>java.sql.Timestamp</code> object.
725      *
726      * @param columnName the SQL name of the column
727      * @return the column value; if the value is SQL <code>NULL</code>, the
728      * value returned is <code>null</code>
729      * @exception SQLException if a database access error occurs
730      */

731     public Timestamp getTimestamp(String JavaDoc columnName) throws SQLException {
732         String JavaDoc str = getString(columnName);
733         return (str == null) ? null : Timestamp.valueOf(str);
734     }
735
736     /**
737      * Retrieves the value of the designated column in the current row
738      * of this <code>ResultSet</code> object as a stream of
739      * ASCII characters. The value can then be read in chunks from the
740      * stream. This method is particularly
741      * suitable for retrieving large <code>LONGVARCHAR</code> values.
742      * The JDBC driver will
743      * do any necessary conversion from the database format into ASCII.
744      *
745      * <P><B>Note:</B> All the data in the returned stream must be
746      * read prior to getting the value of any other column. The next
747      * call to a getter method implicitly closes the stream. Also, a
748      * stream may return <code>0</code> when the method <code>available</code>
749      * is called whether there is data available or not.
750      *
751      * @param columnName the SQL name of the column
752      * @return a Java input stream that delivers the database column value
753      * as a stream of one-byte ASCII characters.
754      * If the value is SQL <code>NULL</code>,
755      * the value returned is <code>null</code>.
756      * @exception SQLException if a database access error occurs
757      */

758     public InputStream JavaDoc getAsciiStream(String JavaDoc columnName) throws SQLException {
759         String JavaDoc str = getString(columnName);
760         is = new ByteArrayInputStream JavaDoc(str.getBytes());
761         return (str == null) ? null : is;
762     }
763
764     /**
765      * Retrieves the value of the designated column in the current row
766      * of this <code>ResultSet</code> object as a stream of two-byte
767      * Unicode characters. The first byte is the high byte; the second
768      * byte is the low byte.
769      *
770      * The value can then be read in chunks from the
771      * stream. This method is particularly
772      * suitable for retrieving large <code>LONGVARCHAR</code> values.
773      * The JDBC technology-enabled driver will
774      * do any necessary conversion from the database format into Unicode.
775      *
776      * <P><B>Note:</B> All the data in the returned stream must be
777      * read prior to getting the value of any other column. The next
778      * call to a getter method implicitly closes the stream.
779      * Also, a stream may return <code>0</code> when the method
780      * <code>InputStream.available</code> is called, whether there
781      * is data available or not.
782      *
783      * @param columnName the SQL name of the column
784      * @return a Java input stream that delivers the database column value
785      * as a stream of two-byte Unicode characters.
786      * If the value is SQL <code>NULL</code>, the value returned
787      * is <code>null</code>.
788      * @exception SQLException if a database access error occurs
789      * @deprecated use <code>getCharacterStream</code> instead
790      */

791     public InputStream JavaDoc getUnicodeStream(String JavaDoc columnName) throws SQLException {
792         // delegate to getAsciiStream(String)
793
return getAsciiStream(columnName);
794     }
795
796     /**
797      * Retrieves the value of the designated column in the current row
798      * of this <code>ResultSet</code> object as a stream of uninterpreted
799      * <code>byte</code>s.
800      * The value can then be read in chunks from the
801      * stream. This method is particularly
802      * suitable for retrieving large <code>LONGVARBINARY</code>
803      * values.
804      *
805      * <P><B>Note:</B> All the data in the returned stream must be
806      * read prior to getting the value of any other column. The next
807      * call to a getter method implicitly closes the stream. Also, a
808      * stream may return <code>0</code> when the method <code>available</code>
809      * is called whether there is data available or not.
810      *
811      * @param columnName the SQL name of the column
812      * @return a Java input stream that delivers the database column value
813      * as a stream of uninterpreted bytes;
814      * if the value is SQL <code>NULL</code>, the result is <code>null</code>
815      * @exception SQLException if a database access error occurs
816      */

817     public InputStream JavaDoc getBinaryStream(String JavaDoc columnName) throws SQLException {
818         // delegate to getAsciiStream(String)
819
return getAsciiStream(columnName);
820     }
821
822     //=====================================================================
823
// Advanced features:
824
//=====================================================================
825

826     /**
827      * Retrieves the first warning reported by calls on this
828      * <code>ResultSet</code> object.
829      * Subsequent warnings on this <code>ResultSet</code> object
830      * will be chained to the <code>SQLWarning</code> object that
831      * this method returns.
832      *
833      * <P>The warning chain is automatically cleared each time a new
834      * row is read. This method may not be called on a <code>ResultSet</code>
835      * object that has been closed; doing so will cause an
836      * <code>SQLException</code> to be thrown.
837      * <P>
838      * <B>Note:</B> This warning chain only covers warnings caused
839      * by <code>ResultSet</code> methods. Any warning caused by
840      * <code>Statement</code> methods
841      * (such as reading OUT parameters) will be chained on the
842      * <code>Statement</code> object.
843      *
844      * @return the first <code>SQLWarning</code> object reported or
845      * <code>null</code> if there are none
846      * @exception SQLException if a database access error occurs or this method
847      * is called on a closed result set
848      */

849     public SQLWarning getWarnings() throws SQLException {
850         throw new UnsupportedOperationException JavaDoc("ResultSet.getWarnings() unsupported");
851     }
852
853     /**
854      * Clears all warnings reported on this <code>ResultSet</code> object.
855      * After this method is called, the method <code>getWarnings</code>
856      * returns <code>null</code> until a new warning is
857      * reported for this <code>ResultSet</code> object.
858      *
859      * @exception SQLException if a database access error occurs
860      */

861     public void clearWarnings() throws SQLException {
862         throw new UnsupportedOperationException JavaDoc("ResultSet.clearWarnings() unsupported");
863     }
864
865     /**
866      * Retrieves the name of the SQL cursor used by this <code>ResultSet</code>
<