KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > in > co > daffodil > db > jdbc > DaffodilDBResultSet


1
2 package in.co.daffodil.db.jdbc;
3
4 import java.io.*;
5 import java.math.BigDecimal JavaDoc;
6 import java.sql.*;
7 import java.sql.Date JavaDoc;
8 import java.util.Calendar JavaDoc;
9
10 import com.daffodilwoods.daffodildb.client.*;
11 import com.daffodilwoods.daffodildb.server.datadictionarysystem._ColumnCharacteristics;
12 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Datatype;
13 import com.daffodilwoods.database.resource.DException;
14
15 /**
16  * A table of data representing a database result set, which
17  * is usually generated by executing a statement that queries the database.
18  *
19  * <P>A <code>ResultSet</code> object maintains a cursor pointing
20  * to its current row of data. Initially the cursor is positioned
21  * before the first row. The <code>next</code> method moves the
22  * cursor to the next row, and because it returns <code>false</code>
23  * when there are no more rows in the <code>ResultSet</code> object,
24  * it can be used in a <code>while</code> loop to iterate through
25  * the result set.
26  * <P>
27  * A default <code>ResultSet</code> object is not updatable and
28  * has a cursor that moves forward only. Thus, it is possible to
29  * iterate through it only once and only from the first row to the
30  * last row. New methods in the JDBC 2.0 API make it possible to
31  * produce <code>ResultSet</code> objects that are scrollable and/or
32  * updatable. The following code fragment, in which <code>con</code>
33  * is a valid <code>Connection</code> object, illustrates how to make
34  * a result set that is scrollable and insensitive to updates by others, and
35  * that is updatable. See <code>ResultSet</code> fields for other
36  * options.
37  * <PRE>
38  *
39  * Statement stmt = con.createStatement(
40  * ResultSet.TYPE_SCROLL_INSENSITIVE,
41  * ResultSet.CONCUR_UPDATABLE);
42  * ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
43  * // rs will be scrollable, will not show changes made by others,
44  * // and will be updatable
45  *
46  * </PRE>
47  * The <code>ResultSet</code> interface provides
48  * <code>getXXX</code> methods for retrieving column values from
49  * the current row.
50  * Values can be retrieved using either the index number of the
51  * column or the name of the column. In general, using the
52  * column index will be more efficient. Columns are numbered from 1.
53  * For maximum portability, result set columns within each row should be
54  * read in left-to-right order, and each column should be read only once.
55  *
56  * <P>For the <code>getXXX</code> methods, a JDBC driver attempts
57  * to convert the underlying data to the Java type specified in the
58  * <code>XXX</code> part of the <code>getXXX</code> method and
59  * returns a suitable Java value. The JDBC specification
60  * has a table showing the allowable mappings
61  * from SQL types to Java types with the <code>ResultSet.getXXX</code>
62  * methods.
63  * <P>
64  * <P>Column names used as input to <code>getXXX</code> methods are case
65  * insensitive. When a <code>getXXX</code> method is called with
66  * a column name and several columns have the same name,
67  * the value of the first matching column will be returned.
68  * The column name option is
69  * designed to be used when column names are used in the SQL
70  * query that generated the result set.
71  * For columns that are NOT explicitly named in the query, it
72  * is best to use column numbers. If column names are used, there is
73  * no way for the programmer to guarantee that they actually refer to
74  * the intended columns.
75  * <P>
76  * A set of <code>updateXXX</code> methods were added to this interface
77  * in the JDBC 2.0 API (Java<sup><font size=-2>TM</font></sup> 2 SDK,
78  * Standard Edition, version 1.2). The comments regarding parameters
79  * to the <code>getXXX</code> methods also apply to parameters to the
80  * <code>updateXXX</code> methods.
81  *<P>
82  * The <code>updateXXX</code> methods may be used in two ways:
83  * <ol>
84  * <LI>to update a column value in the current row. In a scrollable
85  * <code>ResultSet</code> object, the cursor can be moved backwards
86  * and forwards, to an absolute position, or to a position
87  * relative to the current row.
88  * The following code fragment updates the <code>NAME</code> column
89  * in the fifth row of the <code>ResultSet</code> object
90  * <code>rs</code> and then uses the method <code>updateRow</code>
91  * to update the data source table from which <code>rs</code> was derived.
92  * <PRE>
93  *
94  * rs.absolute(5); // moves the cursor to the fifth row of rs
95  * rs.updateString("NAME", "AINSWORTH"); // updates the
96  * // <code>NAME</code> column of row 5 to be <code>AINSWORTH</code>
97  * rs.updateRow(); // updates the row in the data source
98  *
99  * </PRE>
100  * <LI>to insert column values into the insert row. An updatable
101  * <code>ResultSet</code> object has a special row associated with
102  * it that serves as a staging area for building a row to be inserted.
103  * The following code fragment moves the cursor to the insert row, builds
104  * a three-column row, and inserts it into <code>rs</code> and into
105  * the data source table using the method <code>insertRow</code>.
106  * <PRE>
107  *
108  * rs.moveToInsertRow(); // moves cursor to the insert row
109  * rs.updateString(1, "AINSWORTH"); // updates the
110  * // first column of the insert row to be <code>AINSWORTH</code>
111  * rs.updateInt(2,35); // updates the second column to be <code>35</code>
112  * rs.updateBoolean(3, true); // updates the third row to <code>true</code>
113  * rs.insertRow();
114  * rs.moveToCurrentRow();
115  *
116  * </PRE>
117  * </ol>
118  * <P>A <code>ResultSet</code> object is automatically closed when the
119  * <code>Statement</code> object that
120  * generated it is closed, re-executed, or used
121  * to retrieve the next result from a sequence of multiple results.
122  *
123  * <P>The number, types and properties of a <code>ResultSet</code>
124  * object's columns are provided by the <code>ResulSetMetaData</code>
125  * object returned by the <code>ResultSet.getMetaData</code> method.
126  *
127  * @see Statement#executeQuery
128  * @see Statement#getResultSet
129  * @see ResultSetMetaData
130  *
131  * <br><br>
132  * <B>Last Updated </B>
133  * <U> Dec. 20,2004 </U><br>
134  * <I>Purpose :To provide method synchronization . </I><br>
135  * <B>Author</B> Manoj Kr. Sheoran<br>
136  *
137   * <br><br>
138  * <B>Last Updated </B>
139  * <U> Jan 31,2005 </U><br>
140  * <I>Purpose :A real time optimization </I><br>
141  * <B>Author</B> Manoj Kr. Sheoran<br>
142
143  *
144   */

145
146 public class DaffodilDBResultSet implements ResultSet {
147
148    private _RecordSetBufferIterator bufferIterator;
149    private DaffodilDBStatement statement;
150    private Navigator navigator;
151    private RowModifier rowModifier;
152    DaffodilDBConnection connection;
153
154    int concurrency = CONCUR_READ_ONLY;
155    int type = TYPE_FORWARD_ONLY;
156    int fetchSize = 0;
157    int fetchDirection = FETCH_FORWARD;
158    DaffodilDBResultSetMetaData metaData;
159    SQLWarning sqlWarning;
160    private _Record currentRecord = null;
161    private int filedCount = 0;
162    private int[] fieldTypeArrary = null;
163    public DaffodilDBResultSet(DaffodilDBStatement statement) throws SQLException {
164       this.statement = statement;
165       connection = (DaffodilDBConnection) statement.getConnection();
166    }
167
168    /**
169     * Moves the cursor down one row from its current position.
170     * A <code>ResultSet</code> cursor is initially positioned
171     * before the first row; the first call to the method
172     * <code>next</code> makes the first row the current row; the
173     * second call makes the second row the current row, and so on.
174     *
175     * <P>If an input stream is open for the current row, a call
176     * to the method <code>next</code> will
177     * implicitly close it. A <code>ResultSet</code> object's
178     * warning chain is cleared when a new row is read.
179     *
180     * @return <code>true</code> if the new current row is valid;
181     * <code>false</code> if there are no more rows
182     * @exception SQLException if a database access error occurs
183     */

184
185    public boolean next() throws SQLException {
186       this.currentRecord = null;
187       checkResultSetStatus("next");
188       return navigator.next();
189    }
190
191    /**
192     * Releases this <code>ResultSet</code> object's database and
193     * JDBC resources immediately instead of waiting for
194     * this to happen when it is automatically closed.
195     *
196     * <P><B>Note:</B> A <code>ResultSet</code> object
197     * is automatically closed by the
198     * <code>Statement</code> object that generated it when
199     * that <code>Statement</code> object is closed,
200     * re-executed, or is used to retrieve the next result from a
201     * sequence of multiple results. A <code>ResultSet</code> object
202     * is also automatically closed when it is garbage collected.
203     *
204     * @exception SQLException if a database access error occurs
205     */

206
207    public void close() throws SQLException {
208       try {
209          if (statement != null) {
210             if (rowModifier != null)
211                bufferIterator.getRecordSetBuffer().removeDataOperationListener(
212                    rowModifier);
213             statement.resultSet = null;
214             statement = null;
215          }
216       } catch (DException ex) {
217          throw ex.getSqlException(null);
218       }
219    }
220
221    /**
222     * Reports whether
223     * the last column read had a value of SQL <code>NULL</code>.
224     * Note that you must first call one of the getter methods
225     * on a column to try to read its value and then call
226     * the method <code>wasNull</code> to see if the value read was
227     * SQL <code>NULL</code>.
228     *
229     * @return <code>true</code> if the last column value read was SQL
230     * <code>NULL</code> and <code>false</code> otherwise
231     * @exception SQLException if a database access error occurs
232     */

233
234    public boolean wasNull() throws SQLException {
235       checkResultSetStatus("wasNull");
236       if (navigator.lastRetrievedColumn == -1) {
237          DException dex = new DException("DSE725", null);
238          throw dex.getSqlException(connection.getLocale());
239       }
240       return navigator.lastRetrievedColumnValue == null;
241    }
242
243
244    /**
245     * Retrieves the value of the designated column in the current row
246     * of this <code>ResultSet</code> object as
247     * a <code>String</code> in the Java programming language.
248     *
249     * @param columnIndex the first column is 1, the second is 2, ...
250     * @return the column value; if the value is SQL <code>NULL</code>, the
251     * value returned is <code>null</code>
252     * @exception SQLException if a database access error occurs
253     */

254
255    public String JavaDoc getString(int columnIndex) throws SQLException {
256       Object JavaDoc columnValue = getObjectFromCurrentRow(columnIndex, Types.VARCHAR);
257       return columnValue == null ? null : columnValue.toString();
258    }
259
260    /**
261     * Retrieves the value of the designated column in the current row
262     * of this <code>ResultSet</code> object as
263     * a <code>boolean</code> in the Java programming language.
264     *
265     * @param columnIndex the first column is 1, the second is 2, ...
266     * @return the column value; if the value is SQL <code>NULL</code>, the
267     * value returned is <code>false</code>
268     * @exception SQLException if a database access error occurs
269     */

270    public boolean getBoolean(int columnIndex) throws SQLException {
271       Boolean JavaDoc columnValue = (Boolean JavaDoc) getObjectFromCurrentRow(columnIndex,
272           16
273           /*Types.BOOLEAN*/
274           );
275       return columnValue == null ? false : columnValue.booleanValue();
276    }
277
278    /**
279     * Retrieves the value of the designated column in the current row
280     * of this <code>ResultSet</code> object as
281     * a <code>byte</code> in the Java programming language.
282     *
283     * @param columnIndex the first column is 1, the second is 2, ...
284     * @return the column value; if the value is SQL <code>NULL</code>, the
285     * value returned is <code>0</code>
286     * @exception SQLException if a database access error occurs
287     */

288
289    public byte getByte(int columnIndex) throws SQLException {
290       Integer JavaDoc columnValue = (Integer JavaDoc) getObjectFromCurrentRow(columnIndex, Types.TINYINT);
291       return columnValue == null ? (byte) 0 : columnValue.byteValue();
292    }
293
294    /**
295     * Retrieves the value of the designated column in the current row
296     * of this <code>ResultSet</code> object as
297     * a <code>short</code> in the Java programming language.
298     *
299     * @param columnIndex the first column is 1, the second is 2, ...
300     * @return the column value; if the value is SQL <code>NULL</code>, the
301     * value returned is <code>0</code>
302     * @exception SQLException if a database access error occurs
303     */

304
305    public short getShort(int columnIndex) throws SQLException {
306       Integer JavaDoc shortValue = (Integer JavaDoc) getObjectFromCurrentRow(columnIndex, Types.SMALLINT);
307       return shortValue == null ? (short) 0 : shortValue.shortValue();
308    }
309
310    /**
311     * Retrieves the value of the designated column in the current row
312     * of this <code>ResultSet</code> object as
313     * an <code>int</code> in the Java programming language.
314     *
315     * @param columnIndex the first column is 1, the second is 2, ...
316     * @return the column value; if the value is SQL <code>NULL</code>, the
317     * value returned is <code>0</code>
318     * @exception SQLException if a database access error occurs
319     */

320
321    public int getInt(int columnIndex) throws SQLException {
322       Integer JavaDoc intValue = (Integer JavaDoc) getObjectFromCurrentRow(columnIndex, Types.INTEGER);
323       return intValue == null ? 0 : intValue.intValue();
324    }
325
326    /**
327     * Retrieves the value of the designated column in the current row
328     * of this <code>ResultSet</code> object as
329     * a <code>long</code> in the Java programming language.
330     *
331     * @param columnIndex the first column is 1, the second is 2, ...
332     * @return the column value; if the value is SQL <code>NULL</code>, the
333     * value returned is <code>0</code>
334     * @exception SQLException if a database access error occurs
335     */

336
337    public long getLong(int columnIndex) throws SQLException {
338       Long JavaDoc longValue = (Long JavaDoc) getObjectFromCurrentRow(columnIndex, Types.BIGINT);
339       return longValue == null ? 0l : longValue.longValue();
340    }
341
342    /**
343     * Retrieves the value of the designated column in the current row
344     * of this <code>ResultSet</code> object as
345     * a <code>float</code> in the Java programming language.
346     *
347     * @param columnIndex the first column is 1, the second is 2, ...
348     * @return the column value; if the value is SQL <code>NULL</code>, the
349     * value returned is <code>0</code>
350     * @exception SQLException if a database access error occurs
351     */

352
353    public float getFloat(int columnIndex) throws SQLException {
354       Float JavaDoc floatValue = (Float JavaDoc) getObjectFromCurrentRow(columnIndex, Types.REAL);
355       return floatValue == null ? 0f : floatValue.floatValue();
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>double</code> in the Java programming language.
362     *
363     * @param columnIndex the first column is 1, the second is 2, ...
364     * @return the column value; if the value is SQL <code>NULL</code>, the
365     * value returned is <code>0</code>
366     * @exception SQLException if a database access error occurs
367     */

368
369    public double getDouble(int columnIndex) throws SQLException {
370       Double JavaDoc doubleValue = (Double JavaDoc) getObjectFromCurrentRow(columnIndex, Types.DOUBLE);
371       return doubleValue == null ? 0.0 : doubleValue.doubleValue();
372    }
373
374    /**
375     * Retrieves the value of the designated column in the current row
376     * of this <code>ResultSet</code> object as
377     * a <code>java.sql.BigDecimal</code> in the Java programming language.
378     *
379     * @param columnIndex the first column is 1, the second is 2, ...
380     * @param scale the number of digits to the right of the decimal point
381     * @return the column value; if the value is SQL <code>NULL</code>, the
382     * value returned is <code>null</code>
383     * @exception SQLException if a database access error occurs
384     * @deprecated
385     */

386
387    public BigDecimal JavaDoc getBigDecimal(int columnIndex, int scale) throws
388        SQLException {
389       BigDecimal JavaDoc columnValue = (BigDecimal JavaDoc) getObjectFromCurrentRow(columnIndex, Types.DECIMAL);
390       if (columnValue == null || scale == -1)
391          return columnValue;
392       return columnValue.setScale(scale, columnValue.ROUND_DOWN);
393    }
394
395    /**
396     * Retrieves the value of the designated column in the current row
397     * of this <code>ResultSet</code> object as
398     * a <code>byte</code> array in the Java programming language.
399     * The bytes represent the raw values returned by the driver.
400     *
401     * @param columnIndex the first column is 1, the second is 2, ...
402     * @return the column value; if the value is SQL <code>NULL</code>, the
403     * value returned is <code>null</code>
404     * @exception SQLException if a database access error occurs
405     */

406
407    public byte[] getBytes(int columnIndex) throws SQLException {
408       byte[] columnValue = (byte[]) getObjectFromCurrentRow(columnIndex, Types.BINARY);
409       return columnValue;
410    }
411
412    /**
413     * Retrieves the value of the designated column in the current row
414     * of this <code>ResultSet</code> object as
415     * a <code>java.sql.Date</code> object in the Java programming language.
416     *
417     * @param columnIndex the first column is 1, the second is 2, ...
418     * @return the column value; if the value is SQL <code>NULL</code>, the
419     * value returned is <code>null</code>
420     * @exception SQLException if a database access error occurs
421     */

422
423    public java.sql.Date JavaDoc getDate(int columnIndex) throws SQLException {
424       return getDate(columnIndex, null);
425    }
426
427    /**
428     * Retrieves the value of the designated column in the current row
429     * of this <code>ResultSet</code> object as
430     * a <code>java.sql.Time</code> object in the Java programming language.
431     *
432     * @param columnIndex the first column is 1, the second is 2, ...
433     * @return the column value; if the value is SQL <code>NULL</code>, the
434     * value returned is <code>null</code>
435     * @exception SQLException if a database access error occurs
436     */

437
438    public Time getTime(int columnIndex) throws SQLException {
439       return getTime(columnIndex, null);
440    }
441
442    /**
443     * Retrieves the value of the designated column in the current row
444     * of this <code>ResultSet</code> object as
445     * a <code>java.sql.Timestamp</code> object in the Java programming language.
446     *
447     * @param columnIndex the first column is 1, the second is 2, ...
448     * @return the column value; if the value is SQL <code>NULL</code>, the
449     * value returned is <code>null</code>
450     * @exception SQLException if a database access error occurs
451     */

452
453    public Timestamp getTimestamp(int columnIndex) throws SQLException {
454       return getTimestamp(columnIndex, null);
455    }
456
457    /**
458     * Retrieves the value of the designated column in the current row
459     * of this <code>ResultSet</code> object as
460     * a stream of ASCII characters. The value can then be read in chunks from the
461     * stream. This method is particularly
462     * suitable for retrieving large <char>LONGVARCHAR</char> values.
463     * The JDBC driver will
464     * do any necessary conversion from the database format into ASCII.
465     *
466     * <P><B>Note:</B> All the data in the returned stream must be
467     * read prior to getting the value of any other column. The next
468     * call to a getter method implicitly closes the stream. Also, a
469     * stream may return <code>0</code> when the method
470     * <code>InputStream.available</code>
471     * is called whether there is data available or not.
472     *
473     * @param columnIndex the first column is 1, the second is 2, ...
474     * @return a Java input stream that delivers the database column value
475     * as a stream of one-byte ASCII characters;
476     * if the value is SQL <code>NULL</code>, the
477     * value returned is <code>null</code>
478     * @exception SQLException if a database access error occurs
479     */

480
481    public InputStream getAsciiStream(int columnIndex) throws SQLException {
482       byte[] bytes = getBytes(columnIndex);
483       if (bytes == null)
484          return null;
485       byte[] unicodeBytes;
486       try {
487          unicodeBytes = Utilities.convertBytesToAsciiBytes(bytes);
488       } catch (sun.io.MalformedInputException be) {
489          be.printStackTrace();
490          DException dex = new DException("DSE297", null);
491          throw dex.getSqlException(connection.getLocale());
492       }
493       ByteArrayInputStream in = new ByteArrayInputStream(unicodeBytes);
494       return in;
495    }
496
497    /**
498     * Retrieves the value of the designated column in the current row
499     * of this <code>ResultSet</code> object as
500     * as a stream of two-byte Unicode characters. The first byte is
501     * the high byte; the second byte is the low byte.
502     *
503     * The value can then be read in chunks from the
504     * stream. This method is particularly
505     * suitable for retrieving large <code>LONGVARCHAR</code>values. The
506     * JDBC driver will do any necessary conversion from the database
507     * format into Unicode.
508     *
509     * <P><B>Note:</B> All the data in the returned stream must be
510     * read prior to getting the value of any other column. The next
511     * call to a getter method implicitly closes the stream.
512     * Also, a stream may return <code>0</code> when the method
513     * <code>InputStream.available</code>
514     * is called, whether there is data available or not.
515     *
516     * @param columnIndex the first column is 1, the second is 2, ...
517     * @return a Java input stream that delivers the database column value
518     * as a stream of two-byte Unicode characters;
519     * if the value is SQL <code>NULL</code>, the value returned is
520     * <code>null</code>
521     *
522     * @exception SQLException if a database access error occurs
523     * @deprecated use <code>getCharacterStream</code> in place of
524     * <code>getUnicodeStream</code>
525     */

526
527    public java.io.InputStream JavaDoc getUnicodeStream(int columnIndex) throws
528        SQLException {
529       byte[] bytes = getBytes(columnIndex);
530       if (bytes == null)
531          return null;
532       byte[] unicodeBytes;
533       try {
534          unicodeBytes = Utilities.convertBytesToUnicodeBytes(bytes);
535       } catch (sun.io.MalformedInputException ex) {
536          DException dex = new DException("DSE297", null);
537          throw dex.getSqlException(connection.getLocale());
538       }
539       ByteArrayInputStream in = new ByteArrayInputStream(unicodeBytes);
540       return in;
541    }
542
543    /**
544     * Retrieves the value of the designated column in the current row
545     * of this <code>ResultSet</code> object as a binary stream of
546     * uninterpreted bytes. The value can then be read in chunks from the
547     * stream. This method is particularly
548     * suitable for retrieving large <code>LONGVARBINARY</code> values.
549     *
550     * <P><B>Note:</B> All the data in the returned stream must be
551     * read prior to getting the value of any other column. The next
552     * call to a getter method implicitly closes the stream. Also, a
553     * stream may return <code>0</code> when the method
554     * <code>InputStream.available</code>
555     * is called whether there is data available or not.
556     *
557     * @param columnIndex the first column is 1, the second is 2, ...
558     * @return a Java input stream that delivers the database column value
559     * as a stream of uninterpreted bytes;
560     * if the value is SQL <code>NULL</code>, the value returned is
561     * <code>null</code>
562     * @exception SQLException if a database access error occurs
563     */

564
565    public InputStream getBinaryStream(int columnIndex) throws SQLException {
566       byte[] bytes = getBytes(columnIndex);
567       return bytes == null ? null : new ByteArrayInputStream(bytes);
568    }
569
570    /**
571     * Retrieves the value of the designated column in the current row
572     * of this <code>ResultSet</code> object as an <code>Object</code>
573     * in the Java programming language.
574     * If the value is an SQL <code>NULL</code>,
575     * the driver returns a Java <code>null</code>.
576     * This method uses the given <code>Map</code> object
577     * for the custom mapping of the
578     * SQL structured or distinct type that is being retrieved.
579     *
580     * @param i the first column is 1, the second is 2, ...
581     * @param map a <code>java.util.Map</code> object that contains the mapping
582     * from SQL type names to classes in the Java programming language
583     * @return an <code>Object</code> in the Java programming language
584     * representing the SQL value
585     * @exception SQLException if a database access error occurs
586     * @since 1.2
587     */

588
589    public Object JavaDoc getObject(int columnIndex, java.util.Map JavaDoc map) throws
590        SQLException {
591       Object JavaDoc columnValue = getObjectFromCurrentRow(columnIndex, Integer.MIN_VALUE);
592       if (columnValue == null)
593          return null;
594       try {
595          Object JavaDoc newvalue = Utilities.convertObject(columnValue,fieldTypeArrary[columnIndex -1 ] );
596          /*Work done by Manoj told by Parveen Sir. Dec.6 ,2004 */
597          /*
598                 if (fieldTypeArrary[columnIndex -1 ] == Types.NUMERIC || fieldTypeArrary[columnIndex -1 ] == Types.DECIMAL) {
599            int scale = getMetaData().getScale(columnIndex);
600
601            if (scale != -1) {
602             Object newvalue1 = ( (java.math.BigDecimal) newvalue).setScale(scale,
603                  BigDecimal.ROUND_DOWN);
604              newvalue = newvalue1;
605            }
606
607                 }
608                */

609
610          return newvalue;
611       } catch (DException de) {
612          throw de.getSqlException(connection.getLocale());
613       }
614    }
615
616    /**
617     * Retrieves the value of the designated column in the current row
618     * of this <code>ResultSet</code> object as a <code>Ref</code> object
619     * in the Java programming language.
620     *
621     * @param i the first column is 1, the second is 2, ...
622     * @return a <code>Ref</code> object representing an SQL <code>REF</code>
623     * value
624     * @exception SQLException if a database access error occurs
625     * @since 1.2
626     */

627
628    public Ref getRef(int columnIndex) throws SQLException {
629       checkResultSetStatus("getRef");
630       DException dex = new DException("DSE22", new Object JavaDoc[] {"User-defined type"});
631       throw dex.getSqlException(connection.getLocale());
632    }
633
634    /**
635     * Retrieves the value of the designated column in the current row
636     * of this <code>ResultSet</code> object as a <code>Blob</code> object
637     * in the Java programming language.
638     *
639     * @param i the first column is 1, the second is 2, ...
640     * @return a <code>Blob</code> object representing the SQL
641     * <code>BLOB</code> value in the specified column
642     * @exception SQLException if a database access error occurs
643     * @since 1.2
644     */

645
646    public Blob getBlob(int columnIndex) throws SQLException {
647       checkResultSetStatus("getBlob");
648       Blob clob = (Blob) getObject(columnIndex);
649       navigator.lastRetrievedColumnValue = clob == null ? null : clob;
650       return clob;
651    }
652
653    /**
654     * Retrieves the value of the designated column in the current row
655     * of this <code>ResultSet</code> object as a <code>Clob</code> object
656     * in the Java programming language.
657     *
658     * @param i the first column is 1, the second is 2, ...
659     * @return a <code>Clob</code> object representing the SQL
660     * <code>CLOB</code> value in the specified column
661     * @exception SQLException if a database access error occurs
662     * @since 1.2
663     */

664
665    public Clob getClob(int columnIndex) throws SQLException {
666       Clob clob = (Clob) getObjectFromCurrentRow(columnIndex, Types.CLOB);
667       return clob;
668    }
669
670    /**
671     * Retrieves the value of the designated column in the current row
672     * of this <code>ResultSet</code> object as an <code>Array</code> object
673     * in the Java programming language.
674     *
675     * @param i the first column is 1, the second is 2, ...
676     * @return an <code>Array</code> object representing the SQL
677     * <code>ARRAY</code> value in the specified column
678     * @exception SQLException if a database access error occurs
679     * @since 1.2
680     */

681
682    public Array getArray(int columnIndex) throws SQLException {
683       checkResultSetStatus("getArray");
684       DException dex = new DException("DSE22", new Object JavaDoc[] {"User-defined type"});
685       throw dex.getSqlException(connection.getLocale());
686    }
687
688    /**
689     * Retrieves the value of the designated column in the current row
690     * of this <code>ResultSet</code> object as an <code>Object</code>
691     * in the Java programming language.
692     * If the value is an SQL <code>NULL</code>,
693     * the driver returns a Java <code>null</code>.
694     * This method uses the specified <code>Map</code> object for
695     * custom mapping if appropriate.
696     *
697     * @param colName the name of the column from which to retrieve the value
698     * @param map a <code>java.util.Map</code> object that contains the mapping
699     * from SQL type names to classes in the Java programming language
700     * @return an <code>Object</code> representing the SQL value in the
701     * specified column
702     * @exception SQLException if a database access error occurs
703     * @since 1.2
704     */

705
706    public Object JavaDoc getObject(String JavaDoc colName, java.util.Map JavaDoc map) throws
707        SQLException {
708       return getObject(findColumn(colName), map);
709    }
710
711    /**
712     * Retrieves the value of the designated column in the current row
713     * of this <code>ResultSet</code> object as a <code>Ref</code> object
714     * in the Java programming language.
715     *
716     * @param colName the column name
717     * @return a <code>Ref</code> object representing the SQL <code>REF</code>
718     * value in the specified column
719     * @exception SQLException if a database access error occurs
720     * @since 1.2
721     */

722
723    public Ref getRef(String JavaDoc colName) throws SQLException {
724       checkResultSetStatus("getRef");
725       return getRef(findColumn(colName));
726    }
727
728    /**
729     * Retrieves the value of the designated column in the current row
730     * of this <code>ResultSet</code> object as a <code>Blob</code> object
731     * in the Java programming language.
732     *
733     * @param colName the name of the column from which to retrieve the value
734     * @return a <code>Blob</code> object representing the SQL <code>BLOB</code>
735     * value in the specified column
736     * @exception SQLException if a database access error occurs
737     * @since 1.2
738     */

739
740    public Blob getBlob(String JavaDoc colName) throws SQLException {
741       checkResultSetStatus("getBlob");
742       return getBlob(findColumn(colName));
743    }
744
745    /**
746     * Retrieves the value of the designated column in the current row
747     * of this <code>ResultSet</code> object as a <code>Clob</code> object
748     * in the Java programming language.
749     *
750     * @param colName the name of the column from which to retrieve the value
751     * @return a <code>Clob</code> object representing the SQL <code>CLOB</code>
752     * value in the specified column
753     * @exception SQLException if a database access error occurs
754     * @since 1.2
755     */

756
757    public Clob getClob(String JavaDoc colName) throws SQLException {
758       checkResultSetStatus("getClob");
759       return getClob(findColumn(colName));
760    }
761
762    /**
763     * Retrieves the value of the designated column in the current row
764     * of this <code>ResultSet</code> object as an <code>Array</code> object
765     * in the Java programming language.
766     *
767     * @param colName the name of the column from which to retrieve the value
768     * @return an <code>Array</code> object representing the SQL <code>ARRAY</code> value in
769     * the specified column
770     * @exception SQLException if a database access error occurs
771     * @since 1.2
772     */

773
774    public Array getArray(String JavaDoc colName) throws SQLException {
775       checkResultSetStatus("getArray");
776       return getArray(findColumn(colName));
777    }
778
779    /**
780     * Retrieves the value of the designated column in the current row
781     * of this <code>ResultSet</code> object as a <code>java.sql.Date</code> object
782     * in the Java programming language.
783     * This method uses the given calendar to construct an appropriate millisecond
784     * value for the date if the underlying database does not store
785     * timezone information.
786     *
787     * @param columnIndex the first column is 1, the second is 2, ...
788     * @param cal the <code>java.util.Calendar</code> object
789     * to use in constructing the date
790     * @return the column value as a <code>java.sql.Date</code> object;
791     * if the value is SQL <code>NULL</code>,
792     * the value returned is <code>null</code> in the Java programming language
793     * @exception SQLException if a database access error occurs
794     * @since 1.2
795     */

796
797    public java.sql.Date JavaDoc getDate(int columnIndex, Calendar JavaDoc cal) throws
798        SQLException {
799       java.sql.Date JavaDoc columnValue = (java.sql.Date JavaDoc) getObjectFromCurrentRow(
800           columnIndex, Types.DATE);
801       if (columnValue == null || cal == null)
802          return columnValue;
803       cal.setTime(columnValue);
804       return new com.daffodilwoods.daffodildb.utils.DBDate(cal.getTime().getTime()
805           /*cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DATE)*/
806           );
807    }
808
809    /**
810     * Retrieves the value of the designated column in the current row
811     * of this <code>ResultSet</code> object as a <code>java.sql.Date</code> object
812     * in the Java programming language.
813     * This method uses the given calendar to construct an appropriate millisecond
814     * value for the date if the underlying database does not store
815     * timezone information.
816     *
817     * @param columnName the SQL name of the column from which to retrieve the value
818     * @param cal the <code>java.util.Calendar</code> object
819     * to use in constructing the date
820     * @return the column value as a <code>java.sql.Date</code> object;
821     * if the value is SQL <code>NULL</code>,
822     * the value returned is <code>null</code> in the Java programming language
823     * @exception SQLException if a database access error occurs
824     * @since 1.2
825     */

826
827    public java.sql.Date JavaDoc getDate(String JavaDoc columnName, Calendar JavaDoc cal) throws
828        SQLException {
829       return getDate(findColumn(columnName), cal);
830    }
831
832    /**
833     * Retrieves the value of the designated column in the current row
834     * of this <code>ResultSet</code> object as a <code>java.sql.Time</code> object
835     * in the Java programming language.
836     * This method uses the given calendar to construct an appropriate millisecond
837     * value for the time if the underlying database does not store
838     * timezone information.
839     *
840     * @param columnIndex the first column is 1, the second is 2, ...
841     * @param cal the <code>java.util.Calendar</code> object
842     * to use in constructing the time
843     * @return the column value as a <code>java.sql.Time</code> object;
844     * if the value is SQL <code>NULL</code>,
845     * the value returned is <code>null</code> in the Java programming language
846     * @exception SQLException if a database access error occurs
847     * @since 1.2
848     * @ todo time problem
849     */

850
851    public Time getTime(int columnIndex, Calendar JavaDoc cal) throws SQLException {
852       Time timeObj = (Time) getObjectFromCurrentRow(columnIndex, Types.TIME);
853       if (timeObj == null)
854          return null;
855       Date JavaDoc timeObject = new com.daffodilwoods.daffodildb.utils.DBDate(timeObj.getTime());
856       if (cal == null) {
857          Time time = new Time(timeObject.getTime());
858          navigator.lastRetrievedColumnValue = time;
859          return time;
860       }
861       cal.setTime(timeObject);
862       Time calTime = new Time(timeObject.getTime()
863                               /*cal.get(Calendar.HOUR),cal.get(Calendar.MINUTE),
864                                               cal.get(Calendar.SECOND) */
);
865       navigator.lastRetrievedColumnValue = calTime;
866       return calTime;
867    }
868
869    /**
870     * Retrieves the value of the designated column in the current row
871     * of this <code>ResultSet</code> object as a <code>java.sql.Time</code> object
872     * in the Java programming language.
873     * This method uses the given calendar to construct an appropriate millisecond
874     * value for the time if the underlying database does not store
875     * timezone information.
876     *
877     * @param columnName the SQL name of the column
878     * @param cal the <code>java.util.Calendar</code> object
879     * to use in constructing the time
880     * @return the column value as a <code>java.sql.Time</code> object;
881     * if the value is SQL <code>NULL</code>,
882     * the value returned is <code>null</code> in the Java programming language
883     * @exception SQLException if a database access error occurs
884     * @since 1.2
885     */

886
887    public Time getTime(String JavaDoc columnName, Calendar JavaDoc cal) throws SQLException {
888       return getTime(findColumn(columnName), cal);
889    }
890
891    /**
892     * Retrieves the value of the designated column in the current row
893     * of this <code>ResultSet</code> object as a <code>java.sql.Timestamp</code> object
894     * in the Java programming language.
895     * This method uses the given calendar to construct an appropriate millisecond
896     * value for the timestamp if the underlying database does not store
897     * timezone information.
898     *
899     * @param columnIndex the first column is 1, the second is 2, ...
900     * @param cal the <code>java.util.Calendar</code> object
901     * to use in constructing the timestamp
902     * @return the column value as a <code>java.sql.Timestamp</code> object;
903     * if the value is SQL <code>NULL</code>,
904     * the value returned is <code>null</code> in the Java programming language
905     * @exception SQLException if a database access error occurs
906     * @since 1.2
907     * @ todo time problem
908     */

909
910    public java.sql.Timestamp JavaDoc getTimestamp(int columnIndex, Calendar JavaDoc cal) throws
911        SQLException {
912       Timestamp timestamp = (Timestamp) getObjectFromCurrentRow(columnIndex,
913           Types.TIMESTAMP);
914       if (timestamp == null || cal == null) {
915          return timestamp;
916       }
917       Date JavaDoc timeObject = new com.daffodilwoods.daffodildb.utils.DBDate(timestamp.getTime());
918       Calendar JavaDoc cal1 = setCalendarAttributes(cal, timeObject);
919       Timestamp calTime = new Timestamp(cal1.getTime().getTime());
920       navigator.lastRetrievedColumnValue = calTime;
921       return calTime;
922    }
923
924    /**
925     * Retrieves the value of the designated column in the current row
926     * of this <code>ResultSet</code> object as a <code>java.sql.Timestamp</code> object
927     * in the Java programming language.
928     * This method uses the given calendar to construct an appropriate millisecond
929     * value for the timestamp if the underlying database does not store
930     * timezone information.
931     *
932     * @param columnName the SQL name of the column
933     * @param cal the <code>java.util.Calendar</code> object
934     * to use in constructing the date
935     * @return the column value as a <code>java.sql.Timestamp</code> object;
936     * if the value is SQL <code>NULL</code>,
937     * the value returned is <code>null</code> in the Java programming language
938     * @exception SQLException if a database access error occurs
939     * @since 1.2
940     */

941
942    public java.sql.Timestamp JavaDoc getTimestamp(String JavaDoc columnName, Calendar JavaDoc cal) throws
943        SQLException {
944       return getTimestamp(findColumn(columnName), cal);
945    }
946
947
948    /**
949     * Retrieves the value of the designated column in the current row
950     * of this <code>ResultSet</code> object as
951     * a <code>String</code> in the Java programming language.
952     *
953     * @param columnName the SQL name of the column
954     * @return the column value; if the value is SQL <code>NULL</code>, the
955     * value returned is <code>null</code>
956     * @exception SQLException if a database access error occurs
957     */

958
959    public String JavaDoc getString(String JavaDoc columnName) throws SQLException {
960       return getString(findColumn(columnName));
961    }
962
963    /**
964     * Retrieves the value of the designated column in the current row
965     * of this <code>ResultSet</code> object as
966     * a <code>boolean</code> in the Java programming language.
967     *
968     * @param columnName the SQL name of the column
969     * @return the column value; if the value is SQL <code>NULL</code>, the
970     * value returned is <code>false</code>
971     * @exception SQLException if a database access error occurs
972     */

973
974    public boolean getBoolean(String JavaDoc columnName) throws SQLException {
975       return getBoolean(findColumn(columnName));
976    }
977
978    /**
979     * Retrieves the value of the designated column in the current row
980     * of this <code>ResultSet</code> object as
981     * a <code>byte</code> in the Java programming language.
982     *
983     * @param columnName the SQL name of the column
984     * @return the column value; if the value is SQL <code>NULL</code>, the
985     * value returned is <code>0</code>
986     * @exception SQLException if a database access error occurs
987     */

988
989    public byte getByte(String JavaDoc columnName) throws SQLException {
990       return getByte(findColumn(columnName));
991    }
992
993    /**
994     * Retrieves the value of the designated column in the current row
995     * of this <code>ResultSet</code> object as
996     * a <code>short</code> in the Java programming language.
997     *
998     * @param columnName the SQL name of the column
999     * @return the column value; if the value is SQL <code>NULL</code>, the
1000    * value returned is <code>0</code>
1001    * @exception SQLException if a database access error occurs
1002    */

1003
1004   public short getShort(String JavaDoc columnName) throws SQLException {
1005      return getShort(findColumn(columnName));
1006   }
1007
1008   /**
1009    * Retrieves the value of the designated column in the current row
1010    * of this <code>ResultSet</code> object as
1011    * an <code>int</code> in the Java programming language.
1012    *
1013    * @param columnName the SQL name of the column
1014    * @return the column value; if the value is SQL <code>NULL</code>, the
1015    * value returned is <code>0</code>
1016    * @exception SQLException if a database access error occurs
1017    */

1018
1019   public int getInt(String JavaDoc columnName) throws SQLException {
1020      return getInt(findColumn(columnName));
1021   }
1022
1023   /**
1024    * Retrieves the value of the designated column in the current row
1025    * of this <code>ResultSet</code> object as
1026    * a <code>long</code> in the Java programming language.
1027    *
1028    * @param columnName the SQL name of the column
1029    * @return the column value; if the value is SQL <code>NULL</code>, the
1030    * value returned is <code>0</code>
1031    * @exception SQLException if a database access error occurs
1032    */

1033
1034   public long getLong(String JavaDoc columnName) throws SQLException {
1035      return getLong(findColumn(columnName));
1036   }
1037
1038   /**
1039    * Retrieves the value of the designated column in the current row
1040    * of this <code>ResultSet</code> object as
1041    * a <code>float</code> in the Java programming language.
1042    *
1043    * @param columnName the SQL name of the column
1044    * @return the column value; if the value is SQL <code>NULL</code>, the
1045    * value returned is <code>0</code>
1046    * @exception SQLException if a database access error occurs
1047    */

1048
1049   public float getFloat(String JavaDoc columnName) throws SQLException {
1050      return getFloat(findColumn(columnName));
1051   }
1052
1053   /**
1054    * Retrieves the value of the designated column in the current row
1055    * of this <code>ResultSet</code> object as
1056    * a <code>double</code> in the Java programming language.
1057    *
1058    * @param columnName the SQL name of the column
1059    * @return the column value; if the value is SQL <code>NULL</code>, the
1060    * value returned is <code>0</code>
1061    * @exception SQLException if a database access error occurs
1062    */

1063
1064   public double getDouble(String JavaDoc columnName) throws SQLException {
1065      return getDouble(findColumn(columnName));
1066   }
1067
1068   /**
1069    * Retrieves the value of the designated column in the current row
1070    * of this <code>ResultSet</code> object as
1071    * a <code>java.math.BigDecimal</code> in the Java programming language.
1072    *
1073    * @param columnName the SQL name of the column
1074    * @param scale the number of digits to the right of the decimal point
1075    * @return the column value; if the value is SQL <code>NULL</code>, the
1076    * value returned is <code>null</code>
1077    * @exception SQLException if a database access error occurs
1078    * @deprecated
1079    */

1080
1081   public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName, int scale) throws
1082       SQLException {
1083      return getBigDecimal(findColumn(columnName), scale);
1084   }
1085
1086   /**
1087    * Retrieves the value of the designated column in the current row
1088    * of this <code>ResultSet</code> object as
1089    * a <code>byte</code> array in the Java programming language.
1090    * The bytes represent the raw values returned by the driver.
1091    *
1092    * @param columnName the SQL name of the column
1093    * @return the column value; if the value is SQL <code>NULL</code>, the
1094    * value returned is <code>null</code>
1095    * @exception SQLException if a database access error occurs
1096    */

1097
1098   public byte[] getBytes(String JavaDoc columnName) throws SQLException {
1099      return getBytes(findColumn(columnName));
1100   }
1101
1102   /**
1103    * Retrieves the value of the designated column in the current row
1104    * of this <code>ResultSet</code> object as
1105    * a <code>java.sql.Date</code> object in the Java programming language.
1106    *
1107    * @param columnName the SQL name of the column
1108    * @return the column value; if the value is SQL <code>NULL</code>, the
1109    * value returned is <code>null</code>
1110    * @exception SQLException if a database access error occurs
1111    */

1112
1113   public java.sql.Date JavaDoc getDate(String JavaDoc columnName) throws SQLException {
1114      return getDate(findColumn(columnName), null);
1115   }
1116
1117   /**
1118    * Retrieves the value of the designated column in the current row
1119    * of this <code>ResultSet</code> object as
1120    * a <code>java.sql.Time</code> object in the Java programming language.
1121    *
1122    * @param columnName the SQL name of the column
1123    * @return the column value;
1124    * if the value is SQL <code>NULL</code>,
1125    * the value returned is <code>null</code>
1126    * @exception SQLException if a database access error occurs
1127    */

1128
1129   public Time getTime(String JavaDoc columnName) throws SQLException {
1130      return getTime(findColumn(columnName), null);
1131   }
1132
1133   /**
1134    * Retrieves the value of the designated column in the current row
1135    * of this <code>ResultSet</code> object as
1136    * a <code>java.sql.Timestamp</code> object.
1137    *
1138    * @param columnName the SQL name of the column
1139    * @return the column value; if the value is SQL <code>NULL</code>, the
1140    * value returned is <code>null</code>
1141    * @exception SQLException if a database access error occurs
1142    */

1143
1144   public java.sql.Timestamp JavaDoc getTimestamp(String JavaDoc columnName) throws SQLException {
1145      return getTimestamp(findColumn(columnName), null);
1146   }
1147
1148   /**
1149    * Retrieves the value of the designated column in the current row
1150    * of this <code>ResultSet</code> object as a stream of
1151    * ASCII characters. The value can then be read in chunks from the
1152    * stream. This method is particularly
1153    * suitable for retrieving large <code>LONGVARCHAR</code> values.
1154    * The JDBC driver will
1155    * do any necessary conversion from the database format into ASCII.
1156    *
1157    * <P><B>Note:</B> All the data in the returned stream must be
1158    * read prior to getting the value of any other column. The next
1159    * call to a getter method implicitly closes the stream. Also, a
1160    * stream may return <code>0</code> when the method <code>available</code>
1161    * is called whether there is data available or not.
1162    *
1163    * @param columnName the SQL name of the column
1164    * @return a Java input stream that delivers the database column value
1165    * as a stream of one-byte ASCII characters.
1166    * If the value is SQL <code>NULL</code>,
1167    * the value returned is <code>null</code>.
1168    * @exception SQLException if a database access error occurs
1169    */

1170
1171   public java.io.InputStream JavaDoc getAsciiStream(String JavaDoc columnName) throws
1172       SQLException {
1173      return getAsciiStream(findColumn(columnName));
1174   }
1175
1176   /**
1177    * Retrieves the value of the designated column in the current row
1178    * of this <code>ResultSet</code> object as a stream of two-byte
1179    * Unicode characters. The first byte is the high byte; the second
1180    * byte is the low byte.
1181    *
1182    * The value can then be read in chunks from the
1183    * stream. This method is particularly
1184    * suitable for retrieving large <code>LONGVARCHAR</code> values.
1185    * The JDBC technology-enabled driver will
1186    * do any necessary conversion from the database format into Unicode.
1187    *
1188    * <P><B>Note:</B> All the data in the returned stream must be
1189    * read prior to getting the value of any other column. The next
1190    * call to a getter method implicitly closes the stream.
1191    * Also, a stream may return <code>0</code> when the method
1192    * <code>InputStream.available</code> is called, whether there
1193    * is data available or not.
1194    *
1195    * @param columnName the SQL name of the column
1196    * @return a Java input stream that delivers the database column value
1197    * as a stream of two-byte Unicode characters.
1198    * If the value is SQL <code>NULL</code>, the value returned
1199    * is <code>null</code>.
1200    * @exception SQLException if a database access error occurs
1201    * @deprecated use <code>getCharacterStream</code> instead
1202    */

1203
1204   public java.io.InputStream JavaDoc getUnicodeStream(String JavaDoc columnName) throws
1205       SQLException {
1206      return getUnicodeStream(findColumn(columnName));
1207   }
1208
1209   /**
1210    * Retrieves the value of the designated column in the current row
1211    * of this <code>ResultSet</code> object as a stream of uninterpreted
1212    * <code>byte</code>s.
1213    * The value can then be read in chunks from the
1214    * stream. This method is particularly
1215    * suitable for retrieving large <code>LONGVARBINARY</code>
1216    * values.
1217    *
1218    * <P><B>Note:</B> All the data in the returned stream must be
1219    * read prior to getting the value of any other column. The next
1220    * call to a getter method implicitly closes the stream. Also, a
1221    * stream may return <code>0</code> when the method <code>available</code>
1222    * is called whether there is data available or not.
1223    *
1224    * @param columnName the SQL name of the column
1225    * @return a Java input stream that delivers the database column value
1226    * as a stream of uninterpreted bytes;
1227    * if the value is SQL <code>NULL</code>, the result is <code>null</code>
1228    * @exception SQLException if a database access error occurs
1229    */

1230
1231   public InputStream getBinaryStream(String JavaDoc columnName) throws SQLException {
1232      return getBinaryStream(findColumn(columnName));
1233   }
1234
1235
1236   /**
1237    * Retrieves the first warning reported by calls on this
1238    * <code>ResultSet</code> object.
1239    * Subsequent warnings on this <code>ResultSet</code> object
1240    * will be chained to the <code>SQLWarning</code> object that
1241    * this method returns.
1242    *
1243    * <P>The warning chain is automatically cleared each time a new
1244    * row is read. This method may not be called on a <code>ResultSet</code>
1245    * object that has been closed; doing so will cause an
1246    * <code>SQLException</code> to be thrown.
1247    * <P>
1248    * <B>Note:</B> This warning chain only covers warnings caused
1249    * by <code>ResultSet</code> methods. Any warning caused by
1250    * <code>Statement</code> methods
1251    * (such as reading OUT parameters) will be chained on the
1252    * <code>Statement</code> object.
1253    *
1254    * @return the first <code>SQLWarning</code> object reported or
1255    * <code>null</code> if there are none
1256    * @exception SQLException if a database access error occurs or this method is
1257    * called on a closed result set
1258    */

1259
1260   public SQLWarning getWarnings() throws SQLException {
1261      checkResultSetStatus("getWarnings");
1262      return sqlWarning;
1263   }
1264
1265   /**
1266    * Clears all warnings reported on this <code>ResultSet</code> object.
1267    * After this method is called, the method <code>getWarnings</code>
1268    * returns <code>null</code> until a new warning is
1269    * reported for this <code>ResultSet</code> object.
1270    *
1271    * @exception SQLException if a database access error occurs
1272    */

1273   public void clearWarnings() throws SQLException {
1274      checkResultSetStatus("clearWarnings");
1275      sqlWarning = null;
1276   }
1277
1278   /**
1279    * Retrieves the name of the SQL cursor used by this <code>ResultSet</code>
1280    * object.
1281    *
1282    * <P>In SQL, a result table is retrieved through a cursor that is
1283    * named. The current row of a result set can be updated or deleted
1284    * using a positioned update/delete statement that references the
1285    * cursor name. To insure that the cursor has the proper isolation
1286    * level to support update, the cursor's <code>SELECT</code> statement
1287    * should be of the form <code>SELECT FOR UPDATE</code>. If
1288    * <code>FOR UPDATE</code> is omitted, the positioned updates may fail.
1289    *
1290    * <P>The JDBC API supports this SQL feature by providing the name of the
1291    * SQL cursor used by a <code>ResultSet</code> object.
1292    * The current row of a <code>ResultSet</code> object
1293    * is also the current row of this SQL cursor.
1294    *
1295    * <P><B>Note:</B> If positioned update is not supported, a
1296    * <code>SQLException</code> is thrown.
1297    *
1298    * @return the SQL name for this <code>ResultSet</code> object's cursor
1299    * @exception SQLException if a database access error occurs
1300    */

1301
1302   public String JavaDoc getCursorName() throws SQLException {
1303      checkResultSetStatus("getCursorName");
1304      DException dex = new DException("DSE16", new Object JavaDoc[] {"getCursorName"});
1305      throw dex.getSqlException(connection.getLocale());
1306   }
1307
1308   /**
1309    * Retrieves the number, types and properties of
1310    * this <code>ResultSet</code> object's columns.
1311    *
1312    * @return the description of this <code>ResultSet</code> object's columns
1313    * @exception SQLException if a database access error occurs
1314    *
1315    * @ todo
1316    */

1317   public ResultSetMetaData getMetaData() throws SQLException {
1318      checkResultSetStatus("getMetaData");
1319      return metaData;
1320   }
1321
1322   /**
1323    * <p>Gets the value of the designated column in the current row
1324    * of this <code>ResultSet</code> object as
1325    * an <code>Object</code> in the Java programming language.
1326    *
1327    * <p>This method will return the value of the given column as a
1328    * Java object. The type of the Java object will be the default
1329    * Java object type corresponding to the column's SQL type,
1330    * following the mapping for built-in types specified in the JDBC
1331    * specification. If the value is an SQL <code>NULL</code>,
1332    * the driver returns a Java <code>null</code>.
1333    *
1334    * <p>This method may also be used to read datatabase-specific
1335    * abstract data types.
1336    *
1337    * In the JDBC 2.0 API, the behavior of method
1338    * <code>getObject</code> is extended to materialize
1339    * data of SQL user-defined types. When a column contains
1340    * a structured or distinct value, the behavior of this method is as
1341    * if it were a call to: <code>getObject(columnIndex,
1342    * this.getStatement().getConnection().getTypeMap())</code>.
1343    *
1344    * @param columnIndex the first column is 1, the second is 2, ...
1345    * @return a <code>java.lang.Object</code> holding the column value
1346    * @exception SQLException if a database access error occurs
1347    */

1348
1349   public Object JavaDoc getObject(int columnIndex) throws SQLException {
1350      try {
1351          return getObjectFromCurrentRow(columnIndex,Integer.MIN_VALUE);
1352      } catch (Exception JavaDoc ex) {
1353          return null;
1354      }
1355   }
1356
1357   /**
1358    * <p>Gets the value of the designated column in the current row
1359    * of this <code>ResultSet</code> object as
1360    * an <code>Object</code> in the Java programming language.
1361    *
1362    * <p>This method will return the value of the given column as a
1363    * Java object. The type of the Java object will be the default
1364    * Java object type corresponding to the column's SQL type,
1365    * following the mapping for built-in types specified in the JDBC
1366    * specification. If the value is an SQL <code>NULL</code>,
1367    * the driver returns a Java <code>null</code>.
1368    * <P>
1369    * This method may also be used to read datatabase-specific
1370    * abstract data types.
1371    * <P>
1372    * In the JDBC 2.0 API, the behavior of the method
1373    * <code>getObject</code> is extended to materialize
1374    * data of SQL user-defined types. When a column contains
1375    * a structured or distinct value, the behavior of this method is as
1376    * if it were a call to: <code>getObject(columnIndex,
1377    * this.getStatement().getConnection().getTypeMap())</code>.
1378    *
1379    * @param columnName the SQL name of the column
1380    * @return a <code>java.lang.Object</code> holding the column value
1381    * @exception SQLException if a database access error occurs
1382    */

1383
1384   public Object JavaDoc getObject(String JavaDoc columnName) throws SQLException {
1385      return getObject(findColumn(columnName), null);
1386   }
1387
1388
1389   /**
1390    * Maps the given <code>ResultSet</code> column name to its
1391    * <code>ResultSet</code> column index.
1392    *
1393    * @param columnName the name of the column
1394    * @return the column index of the given column name
1395    * @exception SQLException if the <code>ResultSet</code> object
1396    * does not contain <code>columnName</code> or a database access error occurs
1397    */

1398
1399   public int findColumn(String JavaDoc columnName) throws SQLException {
1400      checkResultSetStatus("findColumn");
1401      return this.metaData.getColumnIndex(columnName);
1402   }
1403
1404
1405   /**
1406    * Retrieves the value of the designated column in the current row
1407    * of this <code>ResultSet</code> object as a
1408    * <code>java.io.Reader</code> object.
1409    * @return a <code>java.io.Reader</code> object that contains the column
1410    * value; if the value is SQL <code>NULL</code>, the value returned is
1411    * <code>null</code> in the Java programming language.
1412    * @param columnIndex the first column is 1, the second is 2, ...
1413    * @exception SQLException if a database access error occurs
1414    * @since 1.2
1415    */

1416
1417   public Reader getCharacterStream(int columnIndex) throws SQLException {
1418      byte[] columnBytes = getBytes(columnIndex);
1419      return columnBytes == null ? null :
1420          new InputStreamReader(new ByteArrayInputStream(columnBytes));
1421   }
1422
1423   /**
1424    * Retrieves the value of the designated column in the current row
1425    * of this <code>ResultSet</code> object as a
1426    * <code>java.io.Reader</code> object.
1427    *
1428    * @param columnName the name of the column
1429    * @return a <code>java.io.Reader</code> object that contains the column
1430    * value; if the value is SQL <code>NULL</code>, the value returned is
1431    * <code>null</code> in the Java programming language
1432    * @exception SQLException if a database access error occurs
1433    * @since 1.2
1434    */

1435
1436   public Reader getCharacterStream(String JavaDoc columnName) throws SQLException {
1437      return getCharacterStream(findColumn(columnName));
1438   }
1439
1440   /**
1441    * Retrieves the value of the designated column in the current row
1442    * of this <code>ResultSet</code> object as a
1443    * <code>java.math.BigDecimal</code> with full precision.
1444    *
1445    * @param columnIndex the first column is 1, the second is 2, ...
1446    * @return the column value (full precision);
1447    * if the value is SQL <code>NULL</code>, the value returned is
1448    * <code>null</code> in the Java programming language.
1449    * @exception SQLException if a database access error occurs
1450    * @since 1.2
1451    */

1452
1453   public BigDecimal JavaDoc getBigDecimal(int columnIndex) throws SQLException {
1454      return getBigDecimal(columnIndex, -1);
1455   }
1456
1457   /**
1458    * Retrieves the value of the designated column in the current row
1459    * of this <code>ResultSet</code> object as a
1460    * <code>java.math.BigDecimal</code> with full precision.
1461    *
1462    * @param columnName the column name
1463    * @return the column value (full precision);
1464    * if the value is SQL <code>NULL</code>, the value returned is
1465    * <code>null</code> in the Java programming language.
1466    * @exception SQLException if a database access error occurs
1467    * @since 1.2
1468    *
1469    */

1470   public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName) throws SQLException {
1471      return getBigDecimal(findColumn(columnName), -1);
1472   }
1473
1474
1475   /**
1476    * Retrieves whether the cursor is before the first row in
1477    * this <code>ResultSet</code> object.
1478    *
1479    * @return <code>true</code> if the cursor is before the first row;
1480    * <code>false</code> if the cursor is at any other position or the
1481    * result set contains no rows
1482    * @exception SQLException if a database access error occurs
1483    * @since 1.2
1484    */

1485
1486   public boolean isBeforeFirst() throws SQLException {
1487      checkResultSetStatus("isBeforeFirst");
1488      return navigator.isBeforeFirst();
1489   }
1490
1491   /**
1492    * Retrieves whether the cursor is after the last row in
1493    * this <code>ResultSet</code> object.
1494    *
1495    * @return <code>true</code> if the cursor is after the last row;
1496    * <code>false</code> if the cursor is at any other position or the
1497    * result set contains no rows
1498    * @exception SQLException if a database access error occurs
1499    * @since 1.2
1500    */

1501
1502   public boolean isAfterLast() throws SQLException {
1503      checkResultSetStatus("isAfterLast");
1504      return navigator.isAfterLast();
1505   }
1506
1507   /**
1508    * Retrieves whether the cursor is on the first row of
1509    * this <code>ResultSet</code> object.
1510    *
1511    * @return <code>true</code> if the cursor is on the first row;
1512    * <code>false</code> otherwise
1513    * @exception SQLException if a database access error occurs
1514    * @since 1.2
1515    */

1516
1517   public boolean isFirst() throws SQLException {
1518      checkResultSetStatus("isFirst");
1519      return navigator.isFirst();
1520   }
1521
1522   /**
1523    * Retrieves whether the cursor is on the last row of
1524    * this <code>ResultSet</code> object.
1525    * Note: Calling the method <code>isLast</code> may be expensive
1526    * because the JDBC driver
1527    * might need to fetch ahead one row in order to determine
1528    * whether the current row is the last row in the result set.
1529    *
1530    * @return <code>true</code> if the cursor is on the last row;
1531    * <code>false</code> otherwise
1532    * @exception SQLException if a database access error occurs
1533    * @since 1.2
1534    */

1535
1536   public boolean isLast() throws SQLException {
1537      checkResultSetStatus("isLast");
1538      return navigator.isLast();
1539   }
1540
1541   /**
1542    * Moves the cursor to the front of
1543    * this <code>ResultSet</code> object, just before the
1544    * first row. This method has no effect if the result set contains no rows.
1545    *
1546    * @exception SQLException if a database access error
1547    * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
1548    * @since 1.2
1549    */

1550
1551   public void beforeFirst() throws SQLException {
1552       this.currentRecord = null;
1553      checkResultSetStatus("beforeFirst");
1554      navigator.beforeFirst();
1555   }
1556
1557   /**
1558    * Moves the cursor to the end of
1559    * this <code>ResultSet</code> object, just after the
1560    * last row. This method has no effect if the result set contains no rows.
1561    * @exception SQLException if a database access error
1562    * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
1563    * @since 1.2
1564    */

1565
1566   public void afterLast() throws SQLException {
1567       this.currentRecord = null;
1568      checkResultSetStatus("afterLast");
1569      navigator.afterLast();
1570   }
1571
1572   /**
1573    * Moves the cursor to the first row in
1574    * this <code>ResultSet</code> object.
1575    *
1576    * @return <code>true</code> if the cursor is on a valid row;
1577    * <code>false</code> if there are no rows in the result set
1578    * @exception SQLException if a database access error
1579    * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
1580    * @since 1.2
1581    */

1582
1583   public boolean first() throws SQLException {
1584     this.currentRecord = null;
1585      checkResultSetStatus("first");
1586      return navigator.first();
1587   }
1588
1589   /**
1590    * Moves the cursor to the last row in
1591    * this <code>ResultSet</code> object.
1592    *
1593    * @return <code>true</code> if the cursor is on a valid row;
1594    * <code>false</code> if there are no rows in the result set
1595    * @exception SQLException if a database access error
1596    * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
1597    * @since 1.2
1598    */

1599
1600   public boolean last() throws SQLException {
1601       this.currentRecord = null;
1602      checkResultSetStatus("last");
1603      return navigator.last();
1604   }
1605
1606   /**
1607    * Retrieves the current row number. The first row is number 1, the
1608    * second number 2, and so on.
1609    *
1610    * @return the current row number; <code>0</code> if there is no current row
1611    * @exception SQLException if a database access error occurs
1612    * @since 1.2
1613    */

1614
1615   public int getRow() throws SQLException {
1616      checkResultSetStatus("getRow");
1617      return navigator.getRow();
1618   }
1619
1620   /**
1621    * Moves the cursor to the given row number in
1622    * this <code>ResultSet</code> object.
1623    *
1624    * <p>If the row number is positive, the cursor moves to
1625    * the given row number with respect to the
1626    * beginning of the result set. The first row is row 1, the second
1627    * is row 2, and so on.
1628    *
1629    * <p>If the given row number is negative, the cursor moves to
1630    * an absolute row position with respect to
1631    * the end of the result set. For example, calling the method
1632    * <code>absolute(-1)</code> positions the
1633    * cursor on the last row; calling the method <code>absolute(-2)</code>
1634    * moves the cursor to the next-to-last row, and so on.
1635    *
1636    * <p>An attempt to position the cursor beyond the first/last row in
1637    * the result set leaves the cursor before the first row or after
1638    * the last row.
1639    *
1640    * <p><B>Note:</B> Calling <code>absolute(1)</code> is the same
1641    * as calling <code>first()</code>. Calling <code>absolute(-1)</code>
1642    * is the same as calling <code>last()</code>.
1643    *
1644    * @param row the number of the row to which the cursor should move.
1645    * A positive number indicates the row number counting from the
1646    * beginning of the result set; a negative number indicates the
1647    * row number counting from the end of the result set
1648    * @return <code>true</code> if the cursor is on the result set;
1649    * <code>false</code> otherwise
1650    * @exception SQLException if a database access error
1651    * occurs, or the result set type is <code>TYPE_FORWARD_ONLY</code>
1652    * @since 1.2
1653    * @ todo
1654    * ask for Implementation
1655    */

1656
1657   public boolean absolute(int row) throws SQLException {
1658      this.currentRecord = null;
1659      checkResultSetStatus("absolute");
1660      return navigator.absolute(row);
1661   }
1662
1663   /**
1664    * Moves the cursor a relative number of rows, either positive or negative.
1665    * Attempting to move beyond the first/last row in the
1666    * result set positions the cursor before/after the
1667    * the first/last row. Calling <code>relative(0)</code> is valid, but does
1668    * not change the cursor position.
1669    *
1670    * <p>Note: Calling the method <code>relative(1)</code>
1671    * is identical to calling the method <code>next()</code> and
1672    * calling the method <code>relative(-1)</code> is identical
1673    * to calling the method <code>previous()</code>.
1674    *
1675    * @param rows an <code>int</code> specifying the number of rows to
1676    * move from the current row; a positive number moves the cursor
1677    * forward; a negative number moves the cursor backward
1678    * @return <code>true</code> if the cursor is on a row;
1679    * <code>false</code> otherwise
1680    * @exception SQLException if a database access error occurs,
1681    * there is no current row, or the result set type is
1682    * <code>TYPE_FORWARD_ONLY</code>
1683    * @since 1.2
1684    */

1685
1686   public boolean relative(int rows) throws SQLException {
1687       this.currentRecord = null;
1688      checkResultSetStatus("relative");
1689      return navigator.relative(rows);
1690   }
1691
1692   /**
1693    * Moves the cursor to the previous row in this
1694    * <code>ResultSet</code> object.
1695    *
1696    * @return <code>true</code> if the cursor is on a valid row;
1697    * <code>false</code> if it is off the result set
1698    * @exception SQLException if a database access error
1699    * occurs or the result set type is <code>TYPE_FORWARD_ONLY</code>
1700    * @since 1.2
1701    */

1702
1703   public boolean previous() throws SQLException {
1704      this.currentRecord = null;
1705      checkResultSetStatus("previous");
1706      return navigator.previous();
1707   }
1708
1709
1710   /**
1711    * The constant indicating that the rows in a result set will be
1712    * processed in a forward direction; first-to-last.
1713    * This constant is used by the method <code>setFetchDirection</code>
1714    * as a hint to the driver, which the driver may ignore.
1715    * @since 1.2
1716    *
1717    * int FETCH_FORWARD = 1000;
1718    * The constant indicating that the rows in a result set will be
1719    * processed in a reverse direction; last-to-first.
1720    * This constant is used by the method <code>setFetchDirection</code>
1721    * as a hint to the driver, which the driver may ignore.
1722    * @since 1.2
1723    *
1724    * int FETCH_REVERSE = 1001;
1725    *
1726    * The constant indicating that the order in which rows in a
1727    * result set will be processed is unknown.
1728    * This constant is used by the method <code>setFetchDirection</code>
1729    * as a hint to the driver, which the driver may ignore.
1730    *
1731    * int FETCH_UNKNOWN = 1002;
1732    *
1733    * Gives a hint as to the direction in which the rows in this
1734    * <code>ResultSet</code> object will be processed.
1735    * The initial value is determined by the
1736    * <code>Statement</code> object
1737    * that produced this <code>ResultSet</code> object.
1738    * The fetch direction may be changed at any time.
1739    *
1740    * @param direction an <code>int</code> specifying the suggested
1741    * fetch direction; one of <code>ResultSet.FETCH_FORWARD</code>,
1742    * <code>ResultSet.FETCH_REVERSE</code>, or
1743    * <code>ResultSet.FETCH_UNKNOWN</code>
1744    * @exception SQLException if a database access error occurs or
1745    * the result set type is <code>TYPE_FORWARD_ONLY</code> and the fetch
1746    * direction is not <code>FETCH_FORWARD</code>
1747    * @since 1.2
1748    * @see Statement#setFetchDirection
1749    * @see #getFetchDirection
1750    */

1751
1752   public void setFetchDirection(int direction) throws SQLException {
1753      /*SQLException if result set type is TYPE_FORWARD_ONLY and
1754        the fetch direction is not FETCH_FORWARD*/

1755      checkResultSetStatus("setFetchDirection");
1756      if (direction != FETCH_FORWARD && direction != FETCH_REVERSE &&
1757          direction != FETCH_UNKNOWN) {
1758         DException dex = new DException("DSE738",
1759                                         new Object JavaDoc[] {new Integer JavaDoc(direction)});
1760         throw dex.getSqlException(connection.getLocale());
1761      }
1762      if (type == TYPE_FORWARD_ONLY && direction != FETCH_FORWARD) {
1763         DException dex = new DException("DSE415", null);
1764         throw dex.getSqlException(connection.getLocale());
1765      }
1766      fetchDirection = direction;
1767      bufferIterator.getRecordSetBuffer().setFetchDirection(direction);
1768   }
1769
1770   /**
1771    * Retrieves the fetch direction for this
1772    * <code>ResultSet</code> object.
1773    *
1774    * @return the current fetch direction for this <code>ResultSet</code> object
1775    * @exception SQLException if a database access error occurs
1776    * @since 1.2
1777    * @see #setFetchDirection
1778    */

1779
1780   public int getFetchDirection() throws SQLException {
1781      checkResultSetStatus("getFetchDirection");
1782      return fetchDirection;
1783   }
1784
1785   /**
1786    * Gives the JDBC driver a hint as to the number of rows that should
1787    * be fetched from the database when more rows are needed for this
1788    * <code>ResultSet</code> object.
1789    * If the fetch size specified is zero, the JDBC driver
1790    * ignores the value and is free to make its own best guess as to what
1791    * the fetch size should be. The default value is set by the
1792    * <code>Statement</code> object
1793    * that created the result set. The fetch size may be changed at any time.
1794    *
1795    * @param rows the number of rows to fetch
1796    * @exception SQLException if a database access error occurs or the
1797    * condition <code>0 <= rows <= this.getMaxRows()</code> is not satisfied
1798    * @since 1.2
1799    * @see #getFetchSize
1800    */

1801
1802   public void setFetchSize(int rows) throws SQLException {
1803      /*Exception in case 0 <= rows <= this.getMaxRows() not satisfied*/
1804      checkResultSetStatus("setFetchSize");
1805      if (rows < 0 || (statement.getMaxRows() != 0 && rows > statement.getMaxRows())) {
1806         DException dex = new DException("DSE518", null);
1807         throw dex.getSqlException(connection.getLocale());
1808      }
1809      fetchSize = rows;
1810   }
1811
1812   /**
1813    * Retrieves the fetch size for this
1814    * <code>ResultSet</code> object.
1815    *
1816    * @return the current fetch size for this <code>ResultSet</code> object
1817    * @exception SQLException if a database access error occurs
1818    * @since 1.2
1819    * @see #setFetchSize
1820    */

1821
1822   public int getFetchSize() throws SQLException {
1823      checkResultSetStatus("getFetchSize");
1824      return fetchSize;
1825   }
1826
1827   /**
1828    * The constant indicating the type for a <code>ResultSet</code> object
1829    * whose cursor may move only forward.
1830    * @since 1.2
1831    *
1832    * int TYPE_FORWARD_ONLY = 1003;
1833    *
1834    * The constant indicating the type for a <code>ResultSet</code> object
1835    * that is scrollable but generally not sensitive to changes made by others.
1836    * @since 1.2
1837    *
1838    * int TYPE_SCROLL_INSENSITIVE = 1004;
1839    *
1840    * The constant indicating the type for a <code>ResultSet</code> object
1841    * that is scrollable and generally sensitive to changes made by others.
1842    * @since 1.2
1843    *
1844    * int TYPE_SCROLL_SENSITIVE = 1005;
1845    *
1846    * Retrieves the type of this <code>ResultSet</code> object.
1847    * The type is determined by the <code>Statement</code> object
1848    * that created the result set.
1849    *
1850    * @return <code>ResultSet.TYPE_FORWARD_ONLY</code>,
1851    * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>,
1852    * or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
1853    * @exception SQLException if a database access error occurs
1854    * @since 1.2
1855    */

1856
1857   public int getType() throws SQLException {
1858      checkResultSetStatus("getType");
1859      return type;
1860   }
1861
1862   /**
1863    * The constant indicating the concurrency mode for a
1864    * <code>ResultSet</code> object that may NOT be updated.
1865    * @since 1.2
1866    *
1867    * int CONCUR_READ_ONLY = 1007;
1868    *
1869    * The constant indicating the concurrency mode for a
1870    * <code>ResultSet</code> object that may be updated.
1871    * @since 1.2
1872    *
1873    * int CONCUR_UPDATABLE = 1008;
1874    *
1875    * Retrieves the concurrency mode of this <code>ResultSet</code> object.
1876    * The concurrency used is determined by the
1877    * <code>Statement</code> object that created the result set.
1878    *
1879    * @return the concurrency type, either
1880    * <code>ResultSet.CONCUR_READ_ONLY</code>
1881    * or <code>ResultSet.CONCUR_UPDATABLE</code>
1882    * @exception SQLException if a database access error occurs
1883    * @since 1.2
1884    */

1885
1886   public int getConcurrency() throws SQLException {
1887      checkResultSetStatus("getConcurrency");
1888      return concurrency;
1889   }
1890
1891
1892   /**
1893    * Retrieves whether the current row has been updated. The value returned
1894    * depends on whether or not the result set can detect updates.
1895    *
1896    * @return <code>true</code> if both (1) the row has been visibly updated
1897    * by the owner or another and (2) updates are detected
1898    * @exception SQLException if a database access error occurs
1899    * @see DatabaseMetaData#updatesAreDetected
1900    * @since 1.2
1901    */

1902
1903   public boolean rowUpdated() throws SQLException {
1904      checkResultSetStatus("rowUpdated");
1905      checkUpdatable();
1906      return rowModifier.rowUpdated();
1907   }
1908
1909   /**
1910    * Retrieves whether the current row has had an insertion.
1911    * The value returned depends on whether or not this
1912    * <code>ResultSet</code> object can detect visible inserts.
1913    *
1914    * @return <code>true</code> if a row has had an insertion
1915    * and insertions are detected; <code>false</code> otherwise
1916    * @exception SQLException if a database access error occurs
1917    *
1918    * @see DatabaseMetaData#insertsAreDetected
1919    * @since 1.2
1920    */

1921
1922   public boolean rowInserted() throws SQLException {
1923      checkResultSetStatus("rowInserted");
1924      checkUpdatable();
1925      return rowModifier.rowInserted();
1926   }
1927
1928   /**
1929    * Retrieves whether a row has been deleted. A deleted row may leave
1930    * a visible "hole" in a result set. This method can be used to
1931    * detect holes in a result set. The value returned depends on whether
1932    * or not this <code>ResultSet</code> object can detect deletions.
1933    *
1934    * @return <code>true</code> if a row was deleted and deletions are detected;
1935    * <code>false</code> otherwise
1936    * @exception SQLException if a database access error occurs
1937    *
1938    * @see DatabaseMetaData#deletesAreDetected
1939    * @since 1.2
1940    */

1941
1942   public boolean rowDeleted() throws SQLException {
1943      checkResultSetStatus("rowDeleted");
1944      checkUpdatable();
1945      return rowModifier.rowDeleted();
1946   }
1947
1948   /**
1949    * Gives a nullable column a null value.
1950    *
1951    * The updater methods are used to update column values in the
1952    * current row or the insert row. The updater methods do not
1953    * update the underlying database; instead the <code>updateRow</code>
1954    * or <code>insertRow</code> methods are called to update the database.
1955    *
1956    * @param columnIndex the first column is 1, the second is 2, ...
1957    * @exception SQLException if a database access error occurs
1958    * @since 1.2
1959    */

1960
1961   public void updateNull(int columnIndex) throws SQLException {
1962      checkingBeforeUpdate(columnIndex);
1963      checkAllowedNull(columnIndex);
1964      rowModifier.updateObject(columnIndex, null);
1965   }
1966
1967   /**
1968    * Updates the designated column with a <code>boolean</code> value.
1969    * The updater methods are used to update column values in the
1970    * current row or the insert row. The updater methods do not
1971    * update the underlying database; instead the <code>updateRow</code> or
1972    * <code>insertRow</code> methods are called to update the database.
1973    *
1974    * @param columnIndex the first column is 1, the second is 2, ...
1975    * @param x the new column value
1976    * @exception SQLException if a database access error occurs
1977    * @since 1.2
1978    */

1979
1980   public void updateBoolean(int columnIndex, boolean x) throws SQLException {
1981      checkingBeforeUpdate(columnIndex);
1982      rowModifier.updateObject(columnIndex, Utilities.getBooleanValue(x));
1983   }
1984
1985   /**
1986    * Updates the designated column with a <code>byte</code> value.
1987    * The updater methods are used to update column values in the
1988    * current row or the insert row. The updater methods do not
1989    * update the underlying database; instead the <code>updateRow</code> or
1990    * <code>insertRow</code> methods are called to update the database.
1991    *
1992    * @param columnIndex the first column is 1, the second is 2, ...
1993    * @param x the new column value
1994    * @exception SQLException if a database access error occurs
1995    * @since 1.2
1996    */

1997
1998   public void updateByte(int columnIndex, byte x) throws SQLException {
1999      checkingBeforeUpdate(columnIndex);
2000      rowModifier.updateObject(columnIndex, new Byte JavaDoc(x));
2001   }
2002
2003   /**
2004    * Updates the designated column with a <code>short</code> value.
2005    * The updater methods are used to update column values in the
2006    * current row or the insert row. The updater methods do not
2007    * update the underlying database; instead the <code>updateRow</code> or
2008    * <code>insertRow</code> methods are called to update the database.
2009    *
2010    * @param columnIndex the first column is 1, the second is 2, ...
2011    * @param x the new column value
2012    * @exception SQLException if a database access error occurs
2013    * @since 1.2
2014    */

2015   public void updateShort(int columnIndex, short x) throws SQLException {
2016      checkingBeforeUpdate(columnIndex);
2017      rowModifier.updateObject(columnIndex, new Short JavaDoc(x));
2018   }
2019
2020   /**
2021    * Updates the designated column with an <code>int</code> value.
2022    * The updater methods are used to update column values in the
2023    * current row or the insert row. The updater methods do not
2024    * update the underlying database; instead the <code>updateRow</code> or
2025    * <code>insertRow</code> methods are called to update the database.
2026    *
2027    * @param columnIndex the first column is 1, the second is 2, ...
2028    * @param x the new column value
2029    * @exception SQLException if a database access error occurs
2030    * @since 1.2
2031    */

2032   public void updateInt(int columnIndex, int x) throws SQLException {
2033      checkingBeforeUpdate(columnIndex);
2034      rowModifier.updateObject(columnIndex, new Integer JavaDoc(x));
2035   }
2036
2037   /**
2038    * Updates the designated column with a <code>long</code> value.
2039    * The updater methods are used to update column values in the
2040    * current row or the insert row. The updater methods do not
2041    * update the underlying database; instead the <code>updateRow</code> or
2042    * <code>insertRow</code> methods are called to update the database.
2043    *
2044    * @param columnIndex the first column is 1, the second is 2, ...
2045    * @param x the new column value
2046    * @exception SQLException if a database access error occurs
2047    * @since 1.2
2048    */

2049
2050   public void updateLong(int columnIndex, long x) throws SQLException {
2051      checkingBeforeUpdate(columnIndex);
2052      rowModifier.updateObject(columnIndex, new Long JavaDoc(x));
2053   }
2054
2055   /**
2056    * Updates the designated column with a <code>float</code> value.
2057    * The updater methods are used to update column values in the
2058    * current row or the insert row. The updater methods do not
2059    * update the underlying database; instead the <code>updateRow</code> or
2060    * <code>insertRow</code> methods are called to update the database.
2061    *
2062    * @param columnIndex the first column is 1, the second is 2, ...
2063    * @param x the new column value
2064    * @exception SQLException if a database access error occurs
2065    * @since 1.2
2066    */

2067   public void updateFloat(int columnIndex, float x) throws SQLException {
2068      checkingBeforeUpdate(columnIndex);
2069      rowModifier.updateObject(columnIndex, new Float JavaDoc(x));
2070   }
2071
2072   /**
2073    * Updates the designated column with a <code>double</code> value.
2074    * The updater methods are used to update column values in the
2075    * current row or the insert row. The updater methods do not
2076    * update the underlying database; instead the <code>updateRow</code> or
2077    * <code>insertRow</code> methods are called to update the database.
2078    *
2079    * @param columnIndex the first column is 1, the second is 2, ...
2080    * @param x the new column value
2081    * @exception SQLException if a database access error occurs
2082    * @since 1.2
2083    */

2084   public void updateDouble(int columnIndex, double x) throws SQLException {
2085      checkingBeforeUpdate(columnIndex);
2086      rowModifier.updateObject(columnIndex, new Double JavaDoc(x));
2087   }
2088
2089   /**
2090    * Updates the designated column with a <code>java.math.BigDecimal</code>
2091    * value.
2092    * The updater methods are used to update column values in the
2093    * current row or the insert row. The updater methods do not
2094    * update the underlying database; instead the <code>updateRow</code> or
2095    * <code>insertRow</code> methods are called to update the database.
2096    *
2097    * @param columnIndex the first column is 1, the second is 2, ...
2098    * @param x the new column value
2099    * @exception SQLException if a database access error occurs
2100    * @since 1.2
2101    */

2102
2103   public void updateBigDecimal(int columnIndex, BigDecimal JavaDoc x) throws
2104       SQLException {
2105      checkingBeforeUpdate(columnIndex);
2106      rowModifier.updateObject(columnIndex, x);
2107   }
2108
2109   /**
2110    * Updates the designated column with a <code>String</code> value.
2111    * The updater methods are used to update column values in the
2112    * current row or the insert row. The updater methods do not
2113    * update the underlying database; instead the <code>updateRow</code> or
2114    * <code>insertRow</code> methods are called to update the database.
2115    *
2116    * @param columnIndex the first column is 1, the second is 2, ...
2117    * @param x the new column value
2118    * @exception SQLException if a database access error occurs
2119    * @since 1.2
2120    */

2121   public void updateString(int columnIndex, String JavaDoc x) throws SQLException {
2122      checkingBeforeUpdate(columnIndex);
2123      rowModifier.updateObject(columnIndex, x);
2124   }
2125
2126   /**
2127    * Updates the designated column with a <code>byte</code> array value.
2128    * The updater methods are used to update column values in the
2129    * current row or the insert row. The updater methods do not
2130    * update the underlying database; instead the <code>updateRow</code> or
2131    * <code>insertRow</code> methods are called to update the database.
2132    *
2133    * @param columnIndex the first column is 1, the second is 2, ...
2134    * @param x the new column value
2135    * @exception SQLException if a database access error occurs
2136    * @since 1.2
2137    */

2138
2139   public void updateBytes(int columnIndex, byte x[]) throws SQLException {
2140      checkingBeforeUpdate(columnIndex);
2141      try {
2142         Object JavaDoc columnValue = Utilities.convertObject(x,
2143             fieldTypeArrary[columnIndex-1]);
2144         rowModifier.updateObject(columnIndex, columnValue);
2145      } catch (DException de) {
2146         throw de.getSqlException(connection.getLocale());
2147      }
2148   }
2149
2150   /**
2151    * Updates the designated column with a <code>java.sql.Date</code> value.
2152    * The updater methods are used to update column values in the
2153    * current row or the insert row. The updater methods do not
2154    * update the underlying database; instead the <code>updateRow</code> or
2155    * <code>insertRow</code> methods are called to update the database.
2156    *
2157    * @param columnIndex the first column is 1, the second is 2, ...
2158    * @param x the new column value
2159    * @exception SQLException if a database access error occurs
2160    * @since 1.2
2161    */

2162
2163   public void updateDate(int columnIndex, java.sql.Date JavaDoc x) throws SQLException {
2164      checkingBeforeUpdate(columnIndex);
2165      rowModifier.updateObject(columnIndex, x);
2166   }
2167
2168   /**
2169    * Updates the designated column with a <code>java.sql.Time</code> value.
2170    * The updater methods are used to update column values in the
2171    * current row or the insert row. The updater methods do not
2172    * update the underlying database; instead the <code>updateRow</code> or
2173    * <code>insertRow</code> methods are called to update the database.
2174    *
2175    * @param columnIndex the first column is 1, the second is 2, ...
2176    * @param x the new column value
2177    * @exception SQLException if a database access error occurs
2178    * @since 1.2
2179    */

2180
2181   public void updateTime(int columnIndex, java.sql.Time JavaDoc x) throws SQLException {
2182      checkingBeforeUpdate(columnIndex);
2183      rowModifier.updateObject(columnIndex, x);
2184   }
2185
2186   /**
2187    * Updates the designated column with a <code>java.sql.Timestamp</code>
2188    * value.
2189    * The updater methods are used to update column values in the
2190    * current row or the insert row. The updater methods do not
2191    * update the underlying database; instead the <code>updateRow</code> or
2192    * <code>insertRow</code> methods are called to update the database.
2193    *
2194    * @param columnIndex the first column is 1, the second is 2, ...
2195    * @param x the new column value
2196    * @exception SQLException if a database access error occurs
2197    * @since 1.2
2198    */

2199
2200   public void updateTimestamp(int columnIndex, java.sql.Timestamp JavaDoc x) throws
2201       SQLException {
2202      checkingBeforeUpdate(columnIndex);
2203      rowModifier.updateObject(columnIndex, x);
2204   }
2205
2206   /**
2207    * Updates the designated column with an ascii stream value.
2208    * The updater methods are used to update column values in the
2209    * current row or the insert row. The updater methods do not
2210    * update the underlying database; instead the <code>updateRow</code> or
2211    * <code>insertRow</code> methods are called to update the database.
2212    *
2213    * @param columnIndex the first column is 1, the second is 2, ...
2214    * @param x the new column value
2215    * @param length the length of the stream
2216    * @exception SQLException if a database access error occurs
2217    * @since 1.2
2218    */

2219   public void updateAsciiStream(int columnIndex, InputStream x, int length) throws
2220       SQLException {
2221      checkingBeforeUpdate(columnIndex);
2222      byte[] bytes = new byte[length];
2223      try {
2224         x.read(bytes);
2225      } catch (IOException ex) {
2226         DException dex = new DException("DSE146", null);
2227         throw dex.getSqlException(connection.getLocale());
2228      }
2229      rowModifier.updateObject(columnIndex, bytes);
2230   }
2231
2232   /**
2233    * Updates the designated column with a binary stream value.
2234    * The updater methods are used to update column values in the
2235    * current row or the insert row. The updater methods do not
2236    * update the underlying database; instead the <code>updateRow</code> or
2237    * <code>insertRow</code> methods are called to update the database.
2238    *
2239    * @param columnIndex the first column is 1, the second is 2, ...
2240    * @param x the new column value
2241    * @param length the length of the stream
2242    * @exception SQLException if a database access error occurs
2243    * @since 1.2
2244    */

2245
2246   public void updateBinaryStream(int columnIndex, java.io.InputStream JavaDoc x,
2247                                  int length) throws SQLException {
2248      checkingBeforeUpdate(columnIndex);
2249      byte[] bytes = new byte[length];
2250      try {
2251         x.read(bytes);
2252      } catch (IOException ex) {
2253         DException dex = new DException("DSE146", null);
2254         throw dex.getSqlException(connection.getLocale());
2255      }
2256      rowModifier.updateObject(columnIndex, bytes);
2257   }
2258
2259   /**
2260    * Updates the designated column with a character stream value.
2261    * The updater methods are used to update column values in the
2262    * current row or the insert row. The updater methods do not
2263    * update the underlying database; instead the <code>updateRow</code> or
2264    * <code>insertRow</code> methods are called to update the database.
2265    *
2266    * @param columnIndex the first column is 1, the second is 2, ...
2267    * @param x the new column value
2268    * @param length the length of the stream
2269    * @exception SQLException if a database access error occurs
2270    * @since 1.2
2271    */

2272
2273   public void updateCharacterStream(int columnIndex, java.io.Reader JavaDoc x,
2274                                     int length) throws SQLException {
2275      checkingBeforeUpdate(columnIndex);
2276      char[] chars = new char[length];
2277      byte[] bytes = null;
2278      try {
2279         x.read(chars);
2280         bytes = Utilities.convertCharsToBytes(chars);
2281      } catch (java.io.IOException JavaDoc ie) {
2282         DException dex = new DException("DSE297", null);
2283         throw dex.getSqlException(connection.getLocale());
2284      }
2285      rowModifier.updateObject(columnIndex, bytes);
2286   }
2287
2288   /**
2289    * Updates the designated column with an <code>Object</code> value.
2290    * The updater methods are used to update column values in the
2291    * current row or the insert row. The updater methods do not
2292    * update the underlying database; instead the <code>updateRow</code> or
2293    * <code>insertRow</code> methods are called to update the database.
2294    *
2295    * @param columnIndex the first column is 1, the second is 2, ...
2296    * @param x the new column value
2297    * @param scale for <code>java.sql.Types.DECIMA</code>
2298    * or <code>java.sql.Types.NUMERIC</code> types,
2299    * this is the number of digits after the decimal point. For all other
2300    * types this value will be ignored.
2301    * @exception SQLException if a database access error occurs
2302    * @since 1.2
2303    */

2304
2305   public void updateObject(int columnIndex, Object JavaDoc x, int scale) throws
2306       SQLException {
2307      checkingBeforeUpdate(columnIndex);
2308      int type =fieldTypeArrary[columnIndex -1];
2309      if ( (type == Types.NUMERIC || type == Datatype.DECIMAL) && scale != -1) {
2310         try {
2311            x = Utilities.convertObject(x, Types.DECIMAL);
2312         } catch (DException de) {
2313            throw de.getSqlException(connection.getLocale());
2314         }
2315         x = ( (java.math.BigDecimal JavaDoc) x).setScale(scale, BigDecimal.ROUND_DOWN);
2316      }
2317      rowModifier.updateObject(columnIndex, x);
2318   }
2319
2320   /**
2321    * Updates the designated column with an <code>Object</code> value.
2322    * The updater methods are used to update column values in the
2323    * current row or the insert row. The updater methods do not
2324    * update the underlying database; instead the <code>updateRow</code> or
2325    * <code>insertRow</code> methods are called to update the database.
2326    *
2327    * @param columnIndex the first column is 1, the second is 2, ...
2328    * @param x the new column value
2329    * @exception SQLException if a database access error occurs
2330    * @since 1.2
2331    */

2332   public void updateObject(int columnIndex, Object JavaDoc x) throws SQLException {
2333      updateObject(columnIndex, x, -1);
2334   }
2335
2336   /**
2337    * Updates the designated column with a <code>null</code> value.
2338    * The updater methods are used to update column values in the
2339    * current row or the insert row. The updater methods do not
2340    * update the underlying database; instead the <code>updateRow</code> or
2341    * <code>insertRow</code> methods are called to update the database.
2342    *
2343    * @param columnName the name of the column
2344    * @exception SQLException if a database access error occurs
2345    * @since 1.2
2346    */

2347
2348   public void updateNull(String JavaDoc columnName) throws SQLException {
2349      updateNull(findColumn(columnName));
2350   }
2351
2352   /**
2353    * Updates the designated column with a <code>boolean</code> value.
2354    * The updater methods are used to update column values in the
2355    * current row or the insert row. The updater methods do not
2356    * update the underlying database; instead the <code>updateRow</code> or
2357    * <code>insertRow</code> methods are called to update the database.
2358    *
2359    * @param columnName the name of the column
2360    * @param x the new column value
2361    * @exception SQLException if a database access error occurs
2362    * @since 1.2
2363    */

2364
2365   public void updateBoolean(String JavaDoc columnName, boolean x) throws SQLException {
2366      updateBoolean(findColumn(columnName), x);
2367   }
2368
2369   /**
2370    * Updates the designated column with a <code>byte</code> value.
2371    * The updater methods are used to update column values in the
2372    * current row or the insert row. The updater methods do not
2373    * update the underlying database; instead the <code>updateRow</code> or
2374    * <code>insertRow</code> methods are called to update the database.
2375    *
2376    * @param columnName the name of the column
2377    * @param x the new column value
2378    * @exception SQLException if a database access error occurs
2379    * @since 1.2
2380    */

2381
2382   public void updateByte(String JavaDoc columnName, byte x) throws SQLException {
2383      updateByte(findColumn(columnName), x);
2384   }
2385
2386   /**
2387    * Updates the designated column with a <code>short</code> value.
2388    * The updater methods are used to update column values in the
2389    * current row or the insert row. The updater methods do not
2390    * update the underlying database; instead the <code>updateRow</code> or
2391    * <code>insertRow</code> methods are called to update the database.
2392    *
2393    * @param columnName the name of the column
2394    * @param x the new column value
2395    * @exception SQLException if a database access error occurs
2396    * @since 1.2
2397    */

2398
2399   public void updateShort(String JavaDoc columnName, short x) throws SQLException {
2400      updateShort(findColumn(columnName), x);
2401   }
2402
2403   /**
2404    * Updates the designated column with an <code>int</code> value.
2405    * The updater methods are used to update column values in the
2406    * current row or the insert row. The updater methods do not
2407    * update the underlying database; instead the <code>updateRow</code> or
2408    * <code>insertRow</code> methods are called to update the database.
2409    *
2410    * @param columnName the name of the column
2411    * @param x the new column value
2412    * @exception SQLException if a database access error occurs
2413    * @since 1.2
2414    */

2415
2416   public void updateInt(String JavaDoc columnName, int x) throws SQLException {
2417      updateInt(findColumn(columnName), x);
2418   }
2419
2420   /**
2421    * Updates the designated column with a <code>long</code> value.
2422    * The updater methods are used to update column values in the
2423    * current row or the insert row. The updater methods do not
2424    * update the underlying database; instead the <code>updateRow</code> or
2425    * <code>insertRow</code> methods are called to update the database.
2426    *
2427    * @param columnName the name of the column
2428    * @param x the new column value
2429    * @exception SQLException if a database access error occurs
2430    * @since 1.2
2431    */

2432
2433   public void updateLong(String JavaDoc columnName, long x) throws SQLException {
2434      updateLong(findColumn(columnName), x);
2435   }
2436
2437   /**
2438    * Updates the designated column with a <code>float </code> value.
2439    * The updater methods are used to update column values in the
2440    * current row or the insert row. The updater methods do not
2441    * update the underlying database; instead the <code>updateRow</code> or
2442    * <code>insertRow</code> methods are called to update the database.
2443    *
2444    * @param columnName the name of the column
2445    * @param x the new column value
2446    * @exception SQLException if a database access error occurs
2447    * @since 1.2
2448    */

2449
2450   public void updateFloat(String JavaDoc columnName, float x) throws SQLException {
2451      updateFloat(findColumn(columnName), x);
2452   }
2453
2454   /**
2455    * Updates the designated column with a <code>double</code> value.
2456    * The updater methods are used to update column values in the
2457    * current row or the insert row. The updater methods do not
2458    * update the underlying database; instead the <code>updateRow</code> or
2459    * <code>insertRow</code> methods are called to update the database.
2460    *
2461    * @param columnName the name of the column
2462    * @param x the new column value
2463    * @exception SQLException if a database access error occurs
2464    * @since 1.2
2465    */

2466
2467   public void updateDouble(String JavaDoc columnName, double x) throws SQLException {
2468      updateDouble(findColumn(columnName), x);
2469   }
2470
2471   /**
2472    * Updates the designated column with a <code>java.sql.BigDecimal</code>
2473    * value.
2474    * The updater methods are used to update column values in the
2475    * current row or the insert row. The updater methods do not
2476    * update the underlying database; instead the <code>updateRow</code> or
2477    * <code>insertRow</code> methods are called to update the database.
2478    *
2479    * @param columnName the name of the column
2480    * @param x the new column value
2481    * @exception SQLException if a database access error occurs
2482    * @since 1.2
2483    */

2484
2485   public void updateBigDecimal(String JavaDoc columnName, BigDecimal JavaDoc x) throws
2486       SQLException {
2487      updateBigDecimal(findColumn(columnName), x);
2488   }
2489
2490   /**
2491    * Updates the designated column with a <code>String</code> value.
2492    * The updater methods are used to update column values in the
2493    * current row or the insert row. The updater methods do not
2494    * update the underlying database; instead the <code>updateRow</code> or
2495    * <code>insertRow</code> methods are called to update the database.
2496    *
2497    * @param columnName the name of the column
2498    * @param x the new column value
2499    * @exception SQLException if a database access error occurs
2500    * @since 1.2
2501    */

2502
2503   public void updateString(String JavaDoc columnName, String JavaDoc x) throws SQLException {
2504      updateString(findColumn(columnName), x);
2505   }
2506
2507   /**
2508    * Updates the designated column with a byte array value.
2509    *
2510    * The updater methods are used to update column values in the
2511    * current row or the insert row. The updater methods do not
2512    * update the underlying database; instead the <code>updateRow</code>
2513    * or <code>insertRow</code> methods are called to update the database.
2514    *
2515    * @param columnName the name of the column
2516    * @param x the new column value
2517    * @exception SQLException if a database access error occurs
2518    * @since 1.2
2519    */

2520
2521   public void updateBytes(String JavaDoc columnName, byte x[]) throws SQLException {
2522      updateBytes(findColumn(columnName), x);
2523   }
2524
2525   /**
2526    * Updates the designated column with a <code>java.sql.Date</code> value.
2527    * The updater methods are used to update column values in the
2528    * current row or the insert row. The updater methods do not
2529    * update the underlying database; instead the <code>updateRow</code> or
2530    * <code>insertRow</code> methods are called to update the database.
2531    *
2532    * @param columnName the name of the column
2533    * @param x the new column value
2534    * @exception SQLException if a database access error occurs
2535    * @since 1.2
2536    */

2537
2538   public void updateDate(String JavaDoc columnName, java.sql.Date JavaDoc x) throws
2539       SQLException {
2540      updateDate(findColumn(columnName), x);
2541   }
2542
2543   /**
2544    * Updates the designated column with a <code>java.sql.Time</code> value.
2545    * The updater methods are used to update column values in the
2546    * current row or the insert row. The updater methods do not
2547    * update the underlying database; instead the <code>updateRow</code> or
2548    * <code>insertRow</code> methods are called to update the database.
2549    *
2550    * @param columnName the name of the column
2551    * @param x the new column value
2552    * @exception SQLException if a database access error occurs
2553    * @since 1.2
2554    */

2555
2556   public void updateTime(String JavaDoc columnName, java.sql.Time JavaDoc x) throws
2557       SQLException {
2558      updateTime(findColumn(columnName), x);
2559   }
2560
2561   /**
2562    * Updates the designated column with a <code>java.sql.Timestamp</code>
2563    * value.
2564    * The updater methods are used to update column values in the
2565    * current row or the insert row. The updater methods do not
2566    * update the underlying database; instead the <code>updateRow</code> or
2567    * <code>insertRow</code> methods are called to update the database.
2568    *
2569    * @param columnName the name of the column
2570    * @param x the new column value
2571    * @exception SQLException if a database access error occurs
2572    * @since 1.2
2573    */

2574
2575   public void updateTimestamp(String JavaDoc columnName, java.sql.Timestamp JavaDoc x) throws
2576       SQLException {
2577      updateTimestamp(findColumn(columnName), x);
2578   }
2579
2580   /**
2581    * Updates the designated column with an ascii stream value.
2582    * The updater methods are used to update column values in the
2583    * current row or the insert row. The updater methods do not
2584    * update the underlying database; instead the <code>updateRow</code> or
2585    * <code>insertRow</code> methods are called to update the database.
2586    *
2587    * @param columnName the name of the column
2588    * @param x the new column value
2589    * @param length the length of the stream
2590    * @exception SQLException if a database access error occurs
2591    * @since 1.2
2592    */

2593
2594   public void updateAsciiStream(String JavaDoc columnName, InputStream x, int length) throws
2595       SQLException {
2596      updateAsciiStream(findColumn(columnName), x, length);
2597   }
2598
2599   /**
2600    * Updates the designated column with a binary stream value.
2601    * The updater methods are used to update column values in the
2602    * current row or the insert row. The updater methods do not
2603    * update the underlying database; instead the <code>updateRow</code> or
2604    * <code>insertRow</code> methods are called to update the database.
2605    *
2606    * @param columnName the name of the column
2607    * @param x the new column value
2608    * @param length the length of the stream
2609    * @exception SQLException if a database access error occurs
2610    * @since 1.2
2611    */

2612
2613   public void updateBinaryStream(String JavaDoc columnName, java.io.InputStream JavaDoc x,
2614                                  int length) throws SQLException {
2615      updateBinaryStream(findColumn(columnName), x, length);
2616   }
2617
2618   /**
2619    * Updates the designated column with a character stream value.
2620    * The updater methods are used to update column values in the
2621    * current row or the insert row. The updater methods do not
2622    * update the underlying database; instead the <code>updateRow</code> or
2623    * <code>insertRow</code> methods are called to update the database.
2624    *
2625    * @param columnName the name of the column
2626    * @param reader the <code>java.io.Reader</code> object containing
2627    * the new column value
2628    * @param length the length of the stream
2629    * @exception SQLException if a database access error occurs
2630    * @since 1.2
2631    */

2632
2633   public void updateCharacterStream(String JavaDoc columnName, java.io.Reader JavaDoc reader,
2634                                     int length) throws SQLException {
2635      updateCharacterStream(findColumn(columnName), reader, length);
2636   }
2637
2638   /**
2639    * Updates the designated column with an <code>Object</code> value.
2640    * The updater methods are used to update column values in the
2641    * current row or the insert row. The updater methods do not
2642    * update the underlying database; instead the <code>updateRow</code> or
2643    * <code>insertRow</code> methods are called to update the database.
2644    *
2645    * @param columnName the name of the column
2646    * @param x the new column value
2647    * @param scale for <code>java.sql.Types.DECIMAL</code>
2648    * or <code>java.sql.Types.NUMERIC</code> types,
2649    * this is the number of digits after the decimal point. For all other
2650    * types this value will be ignored.
2651    * @exception SQLException if a database access error occurs
2652    * @since 1.2
2653    */

2654
2655   public void updateObject(String JavaDoc columnName, Object JavaDoc x, int scale) throws
2656       SQLException {
2657      updateObject(findColumn(columnName), x, scale);
2658   }
2659
2660   /**
2661    * Updates the designated column with an <code>Object</code> value.
2662    * The updater methods are used to update column values in the
2663    * current row or the insert row. The updater methods do not
2664    * update the underlying database; instead the <code>updateRow</code> or
2665    * <code>insertRow</code> methods are called to update the database.
2666    *
2667    * @param columnName the name of the column
2668    * @param x the new column value
2669    * @exception SQLException if a database access error occurs
2670    * @since 1.2
2671    */

2672
2673   public void updateObject(String JavaDoc columnName, Object JavaDoc x) throws SQLException {
2674      updateObject(findColumn(columnName), x);
2675   }
2676
2677   /**
2678    * Inserts the contents of the insert row into this
2679    * <code>ResultSet</code> object and into the database.
2680    * The cursor must be on the insert row when this method is called.
2681    *
2682    * @exception SQLException if a database access error occurs,
2683    * if this method is called when the cursor is not on the insert row,
2684    * or if not all of non-nullable columns in
2685    * the insert row have been given a value
2686    * @since 1.2
2687    */

2688
2689   public void insertRow() throws SQLException {
2690      checkResultSetStatus("insertRow");
2691      checkUpdatable();
2692      rowModifier.insertInitiate();
2693   }
2694
2695   /**
2696    * Updates the underlying database with the new contents of the
2697    * current row of this <code>ResultSet</code> object.
2698    * This method cannot be called when the cursor is on the insert row.
2699    *
2700    * @exception SQLException if a database access error occurs or
2701    * if this method is called when the cursor is on the insert row
2702    * @since 1.2
2703    */

2704   public void updateRow() throws SQLException {
2705      checkResultSetStatus("updateRow");
2706      checkUpdatable();
2707      rowModifier.updateInitiate();
2708   }
2709
2710   /**
2711    * Deletes the current row from this <code>ResultSet</code> object
2712    * and from the underlying database. This method cannot be called when
2713    * the cursor is on the insert row.
2714    *
2715    * @exception SQLException if a database access error occurs
2716    * or if this method is called when the cursor is on the insert row
2717    * @since 1.2
2718    */

2719
2720   public void deleteRow() throws SQLException {
2721      checkResultSetStatus("deleteRow");
2722      checkUpdatable();
2723      checkValidRow();
2724      rowModifier.deleteInitiate();
2725   }
2726
2727   /**
2728    * Refreshes the current row with its most recent value in
2729    * the database. This method cannot be called when
2730    * the cursor is on the insert row.
2731    *
2732    * <P>The <code>refreshRow</code> method provides a way for an
2733    * application to
2734    * explicitly tell the JDBC driver to refetch a row(s) from the
2735    * database. An application may want to call <code>refreshRow</code> when
2736    * caching or prefetching is being done by the JDBC driver to
2737    * fetch the latest value of a row from the database. The JDBC driver
2738    * may actually refresh multiple rows at once if the fetch size is
2739    * greater than one.
2740    *
2741    * <P> All values are refetched subject to the transaction isolation
2742    * level and cursor sensitivity. If <code>refreshRow</code> is called after
2743    * calling an updater method, but before calling
2744    * the method <code>updateRow</code>, then the
2745    * updates made to the row are lost. Calling the method
2746    * <code>refreshRow</code> frequently will likely slow performance.
2747    *
2748    * @exception SQLException if a database access error
2749    * occurs or if this method is called when the cursor is on the insert row
2750    * @since 1.2
2751    *
2752    * Note: Nothing is done in this method
2753    * @ todo refreshRow
2754    */

2755
2756   public void refreshRow() throws SQLException {
2757      checkResultSetStatus("refreshRow");
2758      throw new UnsupportedOperationException JavaDoc();
2759   }
2760
2761   /**
2762    * Cancels the updates made to the current row in this
2763    * <code>ResultSet</code> object.
2764    * This method may be called after calling an
2765    * updater method(s) and before calling
2766    * the method <code>updateRow</code> to roll back
2767    * the updates made to a row. If no updates have been made or
2768    * <code>updateRow</code> has already been called, this method has no
2769    * effect.
2770    *
2771    * @exception SQLException if a database access error
2772    * occurs or if this method is called when the cursor is
2773    * on the insert row
2774    * @since 1.2
2775    */

2776   public void cancelRowUpdates() throws SQLException {
2777      checkResultSetStatus("cancelRowUpdates");
2778      checkUpdatable();
2779      rowModifier.cancelRowUpdates();
2780   }
2781
2782   /**
2783    * Moves the cursor to the insert row. The current cursor position is
2784    * remembered while the cursor is positioned on the insert row.
2785    *
2786    * The insert row is a special row associated with an updatable
2787    * result set. It is essentially a buffer where a new row may
2788    * be constructed by calling the updater methods prior to
2789    * inserting the row into the result set.
2790    *
2791    * Only the updater, getter,
2792    * and <code>insertRow</code> methods may be
2793    * called when the cursor is on the insert row. All of the columns in
2794    * a result set must be given a value each time this method is
2795    * called before calling <code>insertRow</code>.
2796    * An updater method must be called before a
2797    * getter method can be called on a column value.
2798    *
2799    * @exception SQLException if a database access error occurs
2800    * or the result set is not updatable
2801    * @since 1.2
2802    *
2803    * @ todo moveToInsertRow()
2804    *
2805    */

2806   public void moveToInsertRow() throws SQLException {
2807      checkResultSetStatus("moveToInsertRow");
2808      checkUpdatable();
2809      navigator.storeCurrentPosition();
2810   }
2811
2812   /**
2813    * Moves the cursor to the remembered cursor position, usually the
2814    * current row. This method has no effect if the cursor is not on
2815    * the insert row.
2816    *
2817    * @exception SQLException if a database access error occurs
2818    * or the result set is not updatable
2819    * @since 1.2
2820    */

2821
2822   public void moveToCurrentRow() throws SQLException {
2823      checkResultSetStatus("moveToCurrentRow");
2824      navigator.moveToCurrentRow();
2825   }
2826
2827   /**
2828    * Retrieves the <code>Statement</code> object that produced this
2829    * <code>ResultSet</code> object.
2830    * If the result set was generated some other way, such as by a
2831    * <code>DatabaseMetaData</code> method, this method returns
2832    * <code>null</code>.
2833    *
2834    * @return the <code>Statment</code> object that produced
2835    * this <code>ResultSet</code> object or <code>null</code>
2836    * if the result set was produced some other way
2837    * @exception SQLException if a database access error occurs
2838    * @since 1.2
2839    */

2840
2841   public Statement getStatement() throws SQLException {
2842      checkResultSetStatus("getStatement");
2843      return statement;
2844   }
2845
2846
2847   /**
2848    * The constant indicating that <code>ResultSet</code> objects should not
2849    * be closed when the method <code>Connection.commit</code> is called.
2850    *
2851    * @since 1.4
2852    *
2853    * int HOLD_CURSORS_OVER_COMMIT = 1;
2854    *
2855    * The constant indicating that <code>ResultSet</code> objects should be
2856    * closed when the method <code>Connection.commit</code> is called.
2857    *
2858    * @since 1.4
2859    *
2860    * int CLOSE_CURSORS_AT_COMMIT = 2;
2861    *
2862    * Retrieves the value of the designated column in the current row
2863    * of this <code>ResultSet</code> object as a <code>java.net.URL</code>
2864    * object in the Java programming language.
2865    *
2866    * @param columnIndex the index of the column 1 is the first, 2 is the second,...
2867    * @return the column value as a <code>java.net.URL</code> object;
2868    * if the value is SQL <code>NULL</code>,
2869    * the value returned is <code>null</code> in the Java programming language
2870    * @exception SQLException if a database access error occurs,
2871    * or if a URL is malformed
2872    * @since 1.4
2873    */

2874
2875   public java.net.URL JavaDoc getURL(int columnIndex) throws SQLException {
2876      Object JavaDoc urlString = getObjectFromCurrentRow(columnIndex, Types.CHAR);
2877      if (urlString == null)
2878         return null;
2879      try {
2880         java.net.URL JavaDoc url = new java.net.URL JavaDoc(urlString.toString());
2881         return url;
2882      } catch (java.net.MalformedURLException JavaDoc N) {
2883         DException dex = new DException("DSE525", null);
2884         throw dex.getSqlException( ( (DaffodilDBConnection) statement.
2885                                     getConnection()).getLocale());
2886      }
2887   }
2888
2889   /**
2890    * Retrieves the value of the designated column in the current row
2891    * of this <code>ResultSet</code> object as a <code>java.net.URL</code>
2892    * object in the Java programming language.
2893    *
2894    * @param columnName the SQL name of the column
2895    * @return the column value as a <code>java.net.URL</code> object;
2896    * if the value is SQL <code>NULL</code>,
2897    * the value returned is <code>null</code> in the Java programming language
2898    * @exception SQLException if a database access error occurs
2899    * or if a URL is malformed
2900    * @since 1.4
2901    */

2902
2903   public java.net.URL JavaDoc getURL(String JavaDoc columnName) throws SQLException {
2904      return getURL(findColumn(columnName));
2905   }
2906
2907   /**
2908    * Updates the designated column with a <code>java.sql.Ref</code> value.
2909    * The updater methods are used to update column values in the
2910    * current row or the insert row. The updater methods do not
2911    * update the underlying database; instead the <code>updateRow</code> or
2912    * <code>insertRow</code> methods are called to update the database.
2913    *
2914    * @param columnIndex the first column is 1, the second is 2, ...
2915    * @param x the new column value
2916    * @exception SQLException if a database access error occurs
2917    * @since 1.4
2918    */

2919
2920   public void updateRef(int columnIndex, java.sql.Ref JavaDoc x) throws SQLException {
2921      checkingBeforeUpdate(columnIndex);
2922      DException dex = new DException("DSE22", new Object JavaDoc[] {"User-defined type"});
2923      throw dex.getSqlException(connection.getLocale());
2924   }
2925
2926   /**
2927    * Updates the designated column with a <code>java.sql.Ref</code> value.
2928    * The updater methods are used to update column values in the
2929    * current row or the insert row. The updater methods do not
2930    * update the underlying database; instead the <code>updateRow</code> or
2931    * <code>insertRow</code> methods are called to update the database.
2932    *
2933    * @param columnName the name of the column
2934    * @param x the new column value
2935    * @exception SQLException if a database access error occurs
2936    * @since 1.4
2937    */

2938
2939   public void updateRef(String JavaDoc columnName, java.sql.Ref JavaDoc x) throws SQLException {
2940      updateRef(findColumn(columnName), x);
2941   }
2942
2943   /**
2944    * Updates the designated column with a <code>java.sql.Blob</code> value.
2945    * The updater methods are used to update column values in the
2946    * current row or the insert row. The updater methods do not
2947    * update the underlying database; instead the <code>updateRow</code> or
2948    * <code>insertRow</code> methods are called to update the database.
2949    *
2950    * @param columnIndex the first column is 1, the second is 2, ...
2951    * @param x the new column value
2952    * @exception SQLException if a database access error occurs
2953    * @since 1.4
2954    */

2955
2956   public void updateBlob(int columnIndex, Blob x) throws SQLException {
2957      checkingBeforeUpdate(columnIndex);
2958      rowModifier.updateObject(columnIndex, x);
2959   }
2960
2961   /**
2962    * Updates the designated column with a <code>java.sql.Blob</code> value.
2963    * The updater methods are used to update column values in the
2964    * current row or the insert row. The updater methods do not
2965    * update the underlying database; instead the <code>updateRow</code> or
2966    * <code>insertRow</code> methods are called to update the database.
2967    *
2968    * @param columnName the name of the column
2969    * @param x the new column value
2970    * @exception SQLException if a database access error occurs
2971    * @since 1.4
2972    */

2973
2974   public void updateBlob(String JavaDoc columnName, Blob x) throws SQLException {
2975      updateBlob(findColumn(columnName), x);
2976   }
2977
2978   /**
2979    * Updates the designated column with a <code>java.sql.Clob</code> value.
2980    * The updater methods are used to update column values in the
2981    * current row or the insert row. The updater methods do not
2982    * update the underlying database; instead the <code>updateRow</code> or
2983    * <code>insertRow</code> methods are called to update the database.
2984    *
2985    * @param columnIndex the first column is 1, the second is 2, ...
2986    * @param x the new column value
2987    * @exception SQLException if a database access error occurs
2988    * @since 1.4
2989    */

2990
2991   public void updateClob(int columnIndex, java.sql.Clob JavaDoc x) throws SQLException {
2992      checkingBeforeUpdate(columnIndex);
2993      rowModifier.updateObject(columnIndex, x);
2994   }
2995
2996   /**
2997    * Updates the designated column with a <code>java.sql.Clob</code> value.
2998    * The updater methods are used to update column values in the
2999    * current row or the insert row. The updater methods do not
3000    * update the underlying database; instead the <code>updateRow</code> or
3001    * <code>insertRow</code> methods are called to update the database.
3002    *
3003    * @param columnName the name of the column
3004    * @param x the new column value
3005    * @exception SQLException if a database access error occurs
3006    * @since 1.4
3007    */

3008
3009   public void updateClob(String JavaDoc columnName, java.sql.Clob JavaDoc x) throws
3010       SQLException {
3011      updateClob(findColumn(columnName), x);
3012   }
3013
3014   /**
3015    * Updates the designated column with a <code>java.sql.Array</code> value.
3016    * The updater methods are used to update column values in the
3017    * current row or the insert row. The updater methods do not
3018    * update the underlying database; instead the <code>updateRow</code> or
3019    * <code>insertRow</code> methods are called to update the database.
3020    *
3021    * @param columnIndex the first column is 1, the second is 2, ...
3022    * @param x the new column value
3023    * @exception SQLException if a database access error occurs
3024    * @since 1.4
3025    */

3026
3027   public void updateArray(int columnIndex, java.sql.Array JavaDoc x) throws
3028       SQLException {
3029      checkingBeforeUpdate(columnIndex);
3030      DException dex = new DException("DSE22", new Object JavaDoc[] {"User-defined type"});
3031      throw dex.getSqlException(connection.getLocale());
3032   }
3033
3034   /**
3035    * Updates the designated column with a <code>java.sql.Array</code> value.
3036    * The updater methods are used to update column values in the
3037    * current row or the insert row. The updater methods do not
3038    * update the underlying database; instead the <code>updateRow</code> or
3039    * <code>insertRow</code> methods are called to update the database.
3040    *
3041    * @param columnName the name of the column
3042    * @param x the new column value
3043    * @exception SQLException if a database access error occurs
3044    * @since 1.4
3045    */

3046
3047   public void updateArray(String JavaDoc columnName, java.sql.Array JavaDoc x) throws
3048       SQLException {
3049      updateArray(findColumn(columnName), x);
3050   }
3051
3052   /**----------------------------------------
3053    * Methods Specific To DaffodilDBResultSet
3054    * ----------------------------------------
3055    * */

3056
3057   void setRecordSetBuffer(_RecordSetBuffer recordSetBuffer) throws SQLException {
3058      bufferIterator = recordSetBuffer.getIterator();
3059      _ColumnCharacteristics clmchs = bufferIterator.getRecordSetBuffer().
3060                                      getColumnCharacteristics();
3061      metaData = new DaffodilDBResultSetMetaData(statement.connection);
3062      metaData.setColumnCharacteristics(clmchs);
3063      filedCount = metaData.getColumnCount();
3064      fieldTypeArrary = new int[filedCount];
3065      for (int i = 0; i < filedCount; i++) {
3066          fieldTypeArrary[i] = metaData.getColumnType(i + 1);
3067      }
3068
3069   }
3070
3071   _RecordSetBufferIterator getRecordSetBufferIterator() {
3072      return bufferIterator;
3073   }
3074
3075   public void setConcurreny(int concurrency) throws SQLException {
3076      try {
3077         if (concurrency != CONCUR_READ_ONLY && concurrency != CONCUR_UPDATABLE) {
3078            DException dex = new DException("DSE511",
3079                                            new Object JavaDoc[] {new Integer JavaDoc(concurrency)});
3080            throw dex.getSqlException(connection.getLocale());
3081         }
3082         this.concurrency = concurrency;
3083         if (concurrency == CONCUR_UPDATABLE) {
3084            rowModifier = new RowModifier();
3085            bufferIterator.getRecordSetBuffer().addDataOperationListener(
3086                rowModifier);
3087         }
3088      } catch (DException ex) {
3089         throw ex.getSqlException(null);
3090      }
3091   }
3092
3093   public int getRowCount() throws SQLException {
3094      int count = bufferIterator.getRowCount();
3095      return count;
3096   }
3097
3098   public void setType(int type) throws SQLException {
3099      if (! (type == TYPE_FORWARD_ONLY || type == TYPE_SCROLL_INSENSITIVE ||
3100             type == TYPE_SCROLL_SENSITIVE)) {
3101         DException dex = new DException("DSE1024", null);
3102         throw dex.getSqlException(connection.getLocale());
3103      }
3104      this.type = type;
3105      navigator = new Navigator();
3106   }
3107
3108   private void checkUpdatable() throws SQLException {
3109      if (concurrency != CONCUR_UPDATABLE) {
3110         DException dex = new DException("DSE870", null);
3111         throw dex.getSqlException(connection.getLocale());
3112      }
3113   }
3114
3115   /** @todo checkAllowedNull to be implemented */
3116
3117   private void checkAllowedNull(int columnIndex) throws SQLException {
3118      int status = metaData.isNullable(columnIndex);
3119      if (status == ResultSetMetaData.columnNoNulls) {
3120         DException dex = new DException("DSE750", null);
3121         throw dex.getSqlException(connection.getLocale());
3122      }
3123   }
3124
3125   void addWarning(String JavaDoc reason) {
3126      SQLWarning warning = new SQLWarning(reason);
3127      if (sqlWarning == null)
3128         sqlWarning = warning;
3129      sqlWarning.setNextWarning(warning);
3130   }
3131
3132   private void checkResultSetStatus(String JavaDoc methodName) throws SQLException {
3133      if (statement == null)
3134         throw new DException("DSE5027",
3135                              null).getSqlException(connection.getLocale());
3136      if (connection.isClosed())
3137         throw new DException("DSE279", null).getSqlException(connection.getLocale());
3138   }
3139
3140   private Object JavaDoc getObjectFromCurrentRow(int columnIndex, int columnType) throws
3141      SQLException {
3142      checkResultSetStatus("");
3143      checkValidRow();
3144      checkValidColumn(columnIndex);
3145      navigator.lastRetrievedColumn = columnIndex;
3146      Object JavaDoc columnValue = getObject(columnIndex, columnType);
3147      navigator.lastRetrievedColumnValue = columnValue;
3148      return columnValue;
3149   }
3150
3151   private Object JavaDoc getObject(int columnIndex, int requiredType) throws
3152       SQLException {
3153      Object JavaDoc columnValue = navigator.getObject(columnIndex);
3154      if (columnValue == null)
3155         return columnValue;
3156      try {
3157        int conversionType = requiredType == Integer.MIN_VALUE ? fieldTypeArrary[columnIndex - 1] : requiredType;
3158          return requiredType == Integer.MIN_VALUE &&
3159                  isConversionNotRequired(fieldTypeArrary[columnIndex - 1]) ?
3160                  columnValue :
3161                  Utilities.convertObject(columnValue,conversionType);
3162      } catch (DException d) {
3163         throw d.getSqlException(connection.getLocale());
3164      }
3165   }
3166
3167  private boolean isConversionNotRequired(int type ){
3168      return (type == Types.TINYINT || type == Types.SMALLINT ||
3169              type == Types.BINARY || type == Types.LONGVARBINARY ||
3170              type == Types.VARBINARY || type == Types.BIT || type == Types.LONGVARCHAR) ? false : true;
3171  }
3172   private void checkingBeforeUpdate(int columnIndex) throws SQLException {
3173      checkResultSetStatus("updateNull");
3174      checkValidRow();
3175      checkUpdatable();
3176      checkValidColumn(columnIndex);
3177   }
3178
3179   private void checkValidColumn(int columnIndex) throws SQLException {
3180      if (columnIndex < 1 || columnIndex > filedCount) {
3181         DException dex = new DException("DSE255",
3182                                         new Object JavaDoc[] {metaData.
3183                                         getColumnName(columnIndex),
3184                                         metaData.getTableName(columnIndex)});
3185         throw dex.getSqlException(connection.getLocale());
3186      }
3187   }
3188
3189   private void checkValidRow() throws SQLException {
3190      if (navigator.isBeforeFirst() || navigator.isAfterLast()) {
3191         DException dex = new DException("DSE294", null);
3192         throw dex.getSqlException(connection.getLocale());
3193      }
3194   }
3195
3196   class Navigator {
3197      boolean beforeFirst = true;
3198      boolean afterLast = false;
3199      int currentRow = 0;
3200      int rowCount;
3201      int lastCurrentRow = 0; // used in case of updatable resultSet
3202
int lastRetrievedColumn = -1;
3203      Object JavaDoc lastRetrievedColumnValue = null;
3204
3205
3206      Navigator() throws SQLException {
3207         if (type != ResultSet.TYPE_FORWARD_ONLY)
3208            rowCount = bufferIterator.getRowCount();
3209      }
3210
3211      private void checkScrollable() throws SQLException {
3212         if ( /*resultSetProperties.*/type == TYPE_FORWARD_ONLY) {
3213            DException dex = new DException("DSE871", null);
3214            throw dex.getSqlException(connection.getLocale());
3215         }
3216      }
3217
3218      Object JavaDoc getObject(int columnIndex) throws SQLException {
3219         columnIndex = columnIndex - DaffodilDBDriver.COLUMN_OFFSET;
3220         if (concurrency == CONCUR_UPDATABLE &&
3221             currentRow == 0)
3222            return rowModifier.getObject(columnIndex);
3223        if(currentRecord == null)
3224          currentRecord = (_Record) bufferIterator.getCurrent();
3225
3226         return lastRetrievedColumnValue = (currentRecord == null ? null :
3227                                            currentRecord.getColumnValue(
3228             columnIndex));
3229      }
3230
3231      boolean absolute(int row) throws SQLException {
3232         checkScrollable();
3233         clearUpdateBuffer();
3234         row = row < 0 ? rowCount + row + 1 : row;
3235         if (row <= 0) {
3236            beforeFirst();
3237            return false;
3238         }
3239         if (row > rowCount) {
3240            afterLast();
3241            return false;
3242         }
3243         moveToRow(row);
3244         lastRetrievedColumn = -1;
3245         return true;
3246      }
3247
3248      void afterLast() throws SQLException {
3249         checkScrollable();
3250         clearUpdateBuffer();
3251         beforeFirst = false;
3252         afterLast = true;
3253         currentRow = rowCount + 1;
3254         lastRetrievedColumn = -1;
3255         bufferIterator.bottom();
3256      }
3257
3258      void beforeFirst() throws SQLException {
3259         checkScrollable();
3260         clearUpdateBuffer();
3261         beforeFirst = true;
3262         afterLast = false;
3263         currentRow = 0; // should do this?????
3264
lastRetrievedColumn = -1;
3265         bufferIterator.top();
3266      }
3267
3268      boolean first() throws SQLException {
3269         checkScrollable();
3270         clearUpdateBuffer();
3271         if (bufferIterator.top()) {
3272            currentRow = 1;
3273            lastRetrievedColumn = -1;
3274            beforeFirst = false;
3275            afterLast = false;
3276            return true;
3277         }
3278         return false;
3279      }
3280
3281      int getRow() throws SQLException {
3282         if (beforeFirst || afterLast)
3283            return 0;
3284         return currentRow;
3285      }
3286
3287      boolean isAfterLast() throws SQLException {
3288         return afterLast;
3289      }
3290
3291      boolean isBeforeFirst() throws SQLException {
3292         return beforeFirst;
3293      }
3294
3295      boolean isFirst() throws SQLException {
3296         return currentRow == 1;
3297      }
3298
3299      boolean isLast() throws SQLException {
3300         return bufferIterator.isBottom() && isAfterLast() == false;
3301      }
3302
3303      boolean last() throws SQLException {
3304         checkScrollable();
3305         clearUpdateBuffer();
3306         if (bufferIterator.bottom()) {
3307            currentRow = rowCount;
3308            lastRetrievedColumn = -1;
3309            beforeFirst = false;
3310            afterLast = false;
3311            return true;
3312         }
3313         return false;
3314      }
3315
3316      void moveToCurrentRow() throws SQLException {
3317         clearUpdateBuffer();
3318         lastRetrievedColumn = -1;
3319         if (lastCurrentRow != 0) {
3320            if (currentRow != lastCurrentRow) {
3321               first();
3322               moveToRow(lastCurrentRow);
3323            }
3324            lastCurrentRow = 0;
3325            beforeFirst = false;
3326            afterLast = false;
3327         }
3328      }
3329
3330      /*
3331        Algo :-
3332          Pointer is afterLast, return false;
3333          Pointer is beforeFirst, call the top of the bufferIterator
3334              and return accordingly;
3335          call next of the bufferIterator and return accordingly
3336       */

3337      boolean next() throws SQLException {
3338         clearUpdateBuffer();
3339         lastRetrievedColumn = -1;
3340         if (afterLast)
3341            return false;
3342         if (beforeFirst) {
3343            beforeFirst = false;
3344            if (bufferIterator.top()) {
3345               currentRow = 1;
3346               clearWarnings();
3347               return true;
3348            }
3349            return false;
3350         }
3351         boolean next = bufferIterator.next();
3352         currentRow++;
3353         if (next) {
3354            clearWarnings();
3355            return true;
3356         }
3357         afterLast = true;
3358         return false;
3359      }
3360
3361      /*
3362         Algo :-
3363           Pointer is beforeFirst, return false;
3364           Pointer is afterLast, call the bottom of bufferIterator
3365                and return accordingly
3366           call the previous of the bufferIterator and return accordingly
3367       */

3368      boolean previous() throws SQLException {
3369         checkScrollable();
3370         clearUpdateBuffer();
3371         lastRetrievedColumn = -1;
3372         if (beforeFirst)
3373            return false;
3374         if (afterLast) {
3375            afterLast = false;
3376            currentRow--;
3377            if (bufferIterator.bottom()) {
3378               currentRow = rowCount;
3379               clearWarnings();
3380               return true;
3381            }
3382            return false;
3383         }
3384         boolean previous = bufferIterator.previous();
3385         currentRow--;
3386         if (previous) {
3387            clearWarnings();
3388            return true;
3389         }
3390         currentRow = 0;
3391         beforeFirst = true;
3392         return false;
3393      }
3394
3395      boolean relative(int rows) throws SQLException {
3396         checkScrollable();
3397         clearUpdateBuffer();
3398         if (rows == 0)
3399            return currentRow > 0 && currentRow <= rowCount;
3400         lastRetrievedColumn = -1;
3401         int newRowIndex = currentRow + rows;
3402         if (newRowIndex <= 0) {
3403            beforeFirst();
3404            return false;
3405         }
3406         if (newRowIndex > rowCount) {
3407            afterLast();
3408            return false;
3409         }
3410         moveToRow(newRowIndex);
3411         return true;
3412      }
3413
3414      private void moveToRow(int rowIndex) throws SQLException {
3415         clearUpdateBuffer();
3416         lastRetrievedColumn = -1;
3417         if (currentRow < rowIndex) {
3418            while (currentRow != rowIndex) {
3419               if (currentRow > 0) {
3420                  if (!bufferIterator.next()) {
3421                     break;
3422                  }
3423               }
3424               currentRow++;
3425            }
3426            if (currentRow == rowCount + 1) {
3427               beforeFirst = false;
3428               afterLast = true;
3429            } else {
3430               beforeFirst = false;
3431               afterLast = false;
3432            }
3433         } else if (currentRow > rowIndex) {
3434            while (currentRow != rowIndex) {
3435               if (currentRow <= rowCount) {
3436                  if (!bufferIterator.previous())
3437                     break;
3438               }
3439               currentRow--;
3440            }
3441            if (currentRow == 0) {
3442               beforeFirst = true;
3443               afterLast = false;
3444            } else {
3445               beforeFirst = false;
3446               afterLast = false;
3447            }
3448         }
3449      }
3450
3451      public void storeCurrentPosition() throws SQLException {
3452         clearUpdateBuffer();
3453         lastCurrentRow = currentRow;
3454         beforeFirst = false;
3455         afterLast = false;
3456         currentRow = 0;
3457      }
3458
3459      private void clearUpdateBuffer() throws SQLException {
3460         if (concurrency == CONCUR_UPDATABLE)
3461            rowModifier.cancelRowUpdates();
3462      }
3463   }
3464
3465   /** This class will handle dataModification operations.
3466    * insert, delete and updates and other operations.
3467    */

3468
3469   class RowModifier implements DataOperationListener {
3470      RecordBuffer recordBuffer;
3471      boolean readyToUpdate = false;
3472
3473      RowModifier() {
3474         recordBuffer = new RecordBuffer();
3475      }
3476
3477      Object JavaDoc getObject(int columnIndex) throws SQLException {
3478         return recordBuffer.getColumnValue(columnIndex);
3479      }
3480
3481      void updateObject(int columnIndex, Object JavaDoc columnValue) throws SQLException {
3482         recordBuffer.setUpdateValue(columnIndex, columnValue);
3483         readyToUpdate = true;
3484      }
3485
3486      void cancelRowUpdates() throws SQLException {
3487         recordBuffer.clearData();
3488         readyToUpdate = false;
3489      }
3490
3491      void updateInitiate() throws SQLException {
3492         int[] columnIndexes = recordBuffer.getUpdatedColumns();
3493         Object JavaDoc[] columnValues = recordBuffer.getUpdatedValues();
3494         synchronized (connection) {
3495           if (columnIndexes != null) {
3496             bufferIterator.updateInitiate(columnIndexes, columnValues);
3497           }
3498           readyToUpdate = false;
3499           try {
3500             if (statement.connection.getAutoCommit())
3501               connection.getServerConnection().commit();
3502
3503           }
3504           catch (DException ex) {
3505             throw ex.getSqlException(connection.getLocale());
3506           }
3507         }
3508      }
3509
3510      void insertInitiate() throws SQLException {
3511         int[] columnIndexes = recordBuffer.getUpdatedColumns();
3512         Object JavaDoc[] columnValues = recordBuffer.getUpdatedValues();
3513         synchronized (connection) {
3514             try {
3515              bufferIterator.insertInitiate(columnIndexes, columnValues);
3516              if (statement.connection.getAutoCommit())
3517                 connection.getServerConnection().commit();
3518
3519           } catch (DException de) {
3520              throw de.getSqlException(connection.getLocale());
3521           }
3522            }
3523      }
3524
3525      void deleteInitiate() throws SQLException {
3526         synchronized (connection) {
3527           try {
3528              bufferIterator.deleteInitiate();
3529              if (statement.connection.getAutoCommit())
3530                 connection.getServerConnection().commit();
3531           } catch (DException de) {
3532              throw de.getSqlException(connection.getLocale());
3533           }
3534         }
3535      }
3536
3537      /* not clear about these functions. Details required */
3538
3539      boolean rowUpdated() throws SQLException {
3540         _Record currentRecord = (_Record) bufferIterator.getCurrent();
3541         return recordBuffer.rowUpdated(currentRecord.getIdentity());
3542      }
3543
3544
3545      boolean rowDeleted() throws SQLException {
3546         return false;
3547      }
3548
3549      boolean rowInserted() throws SQLException {
3550         _Record currentRecord = (_Record) bufferIterator.getCurrent();
3551         return recordBuffer.rowInserted(currentRecord.getIdentity());
3552      }
3553
3554      public void operationPerformed(DataOperation dataOperation) {
3555         int operationtype = dataOperation.operationType;
3556         Object JavaDoc key = dataOperation.recordIdentity;
3557         if (operationtype == dataOperation.INSERT)
3558            recordBuffer.addRowInserted(key);
3559         if (operationtype == dataOperation.DELETE)
3560            recordBuffer.removeRowDeleted(key);
3561         if (operationtype == dataOperation.UPDATE)
3562            recordBuffer.addRowUpdated(key);
3563      }
3564   }
3565
3566   private Calendar JavaDoc setCalendarAttributes(Calendar JavaDoc calendar, Date JavaDoc date) {
3567      Timestamp timestamp = new Timestamp(date.getTime());
3568      calendar.clear();
3569      calendar.set(Calendar.YEAR, timestamp.getYear() + 1900);
3570      calendar.set(Calendar.MONTH, timestamp.getMonth());
3571      calendar.set(Calendar.DATE, timestamp.getDate());
3572      calendar.set(Calendar.HOUR, timestamp.getHours());
3573      calendar.set(Calendar.MINUTE, timestamp.getMinutes());
3574      calendar.set(Calendar.SECOND, timestamp.getSeconds());
3575      calendar.set(Calendar.MILLISECOND, timestamp.getNanos() / 0xf4240);
3576      return calendar;
3577   }
3578}
3579
Popular Tags