KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > xml > XmlResultSet


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

18
19 package org.webdocwf.util.xml;
20
21 import java.io.ByteArrayInputStream JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.Reader JavaDoc;
25 import java.io.StringReader JavaDoc;
26 import java.math.BigDecimal JavaDoc;
27 import java.net.URL JavaDoc;
28 import java.sql.*;
29 import java.util.ArrayList JavaDoc;
30 import java.util.Map JavaDoc;
31 import java.util.Calendar JavaDoc;
32
33 /**
34  * Class that implements JDBC ResultSet interface.
35  *
36  * @author Zoran Milakovic
37  */

38 public class XmlResultSet implements ResultSet {
39
40   /** Metadata for this ResultSet */
41   protected ResultSetMetaData resultSetMetaData;
42
43   /** Statement that produced this ResultSet */
44   protected Statement statement;
45
46   /** Helper class that performs the actual file reads */
47   protected XmlReader reader;
48
49   /** Table referenced by the Statement */
50   protected String JavaDoc tableName;
51
52   /** Array of available columns for referenced table */
53   protected String JavaDoc[] columnNames;
54
55   /** Array of column values for referenced table */
56   protected String JavaDoc[] columnValues;
57
58   protected String JavaDoc[] whereColumnNames;
59
60   protected String JavaDoc[] whereColumnValues;
61
62
63     /** Last column name index read */
64     protected int lastIndexRead = -1;
65
66     /** InputStream to keep track of */
67     protected InputStream JavaDoc is;
68
69   /**
70    * Constructor for the XmlResultSet object
71    *
72    * @param statement Statement that produced this ResultSet
73    * @param reader Helper class that performs the actual file reads
74    * @param tableName Table referenced by the Statement
75    * @param columnNames Array of available columns for referenced table
76    * @param whereColumnNames is an array of column names
77    * @param whereColumnValues is an array of column values
78    */

79   protected XmlResultSet(Statement statement, XmlReader reader , String JavaDoc tableName , String JavaDoc[] columnNames
80                          , String JavaDoc[] whereColumnNames , String JavaDoc[] whereColumnValues ) {
81     this.statement = statement;
82     this.reader = reader;
83     this.tableName = tableName;
84     this.columnNames = columnNames;
85     this.whereColumnNames = whereColumnNames;
86     this.whereColumnValues = whereColumnValues;
87   }
88
89
90   public void select() throws SQLException {
91     reader.select( tableName , columnNames , whereColumnNames , whereColumnValues);
92     this.rset = reader.getResultSet();
93   }
94
95   public void selectTableNames() throws SQLException {
96     reader.selectTableNames();
97     this.rset = reader.getResultSet();
98   }
99   public void close() {
100   }
101
102   private int index = 0;
103   private ArrayList JavaDoc rset = new ArrayList JavaDoc();
104   /**
105    *Description of the Method
106    *
107    * @return Description of the Returned Value
108    * @exception SQLException
109    * @since
110    */

111   public boolean next() throws SQLException {
112     boolean retVal = false;
113       try {
114         if( !(rset.size() <= index) ) {
115           this.columnValues = (String JavaDoc[])rset.get( index );
116           index++;
117           retVal = true;
118         } else {
119           index = 0;
120           rset = new ArrayList JavaDoc();
121           this.columnValues = new String JavaDoc[0];
122           retVal = false;
123         }
124       }catch( Exception JavaDoc e ) { throw new SQLException("Error in ResultSet.next() : "+e.getMessage()); }
125     return retVal;
126   }
127
128   public String JavaDoc getString(int i) throws SQLException {
129     try {
130       return this.columnValues[i-1].toString();
131     }catch(Exception JavaDoc e) { throw new SQLException("Error ResultSet.getString( index ) : "+e.getMessage()); }
132   }
133
134   /**
135  * Reports whether
136  * the last column read had a value of SQL <code>NULL</code>.
137  * Note that you must first call one of the getter methods
138  * on a column to try to read its value and then call
139  * the method <code>wasNull</code> to see if the value read was
140  * SQL <code>NULL</code>.
141  *
142  * @return <code>true</code> if the last column value read was SQL
143  * <code>NULL</code> and <code>false</code> otherwise
144  * @exception SQLException if a database access error occurs
145  */

146 public boolean wasNull() throws SQLException {
147     if(lastIndexRead >= 0) {
148         return getString(lastIndexRead) == null;
149     } else {
150         throw new SQLException("No previous getter method called");
151     }
152 }
153
154 //======================================================================
155
// Methods for accessing results by column index
156
//======================================================================
157

158
159 /**
160  * Retrieves the value of the designated column in the current row
161  * of this <code>ResultSet</code> object as
162  * a <code>boolean</code> in the Java programming language.
163  *
164  * @param columnIndex the first column is 1, the second is 2, ...
165  * @return the column value; if the value is SQL <code>NULL</code>, the
166  * value returned is <code>false</code>
167  * @exception SQLException if a database access error occurs
168  */

169 public boolean getBoolean(int columnIndex) throws SQLException {
170   String JavaDoc str = getString(columnIndex);
171   return (str == null) ? false : Boolean.valueOf(str).booleanValue();
172 }
173
174 /**
175  * Retrieves the value of the designated column in the current row
176  * of this <code>ResultSet</code> object as
177  * a <code>byte</code> in the Java programming language.
178  *
179  * @param columnIndex the first column is 1, the second is 2, ...
180  * @return the column value; if the value is SQL <code>NULL</code>, the
181  * value returned is <code>0</code>
182  * @exception SQLException if a database access error occurs
183  */

184 public byte getByte(int columnIndex) throws SQLException {
185   String JavaDoc str = getString(columnIndex);
186   return (str == null) ? 0 : Byte.parseByte(str);
187 }
188
189 /**
190  * Retrieves the value of the designated column in the current row
191  * of this <code>ResultSet</code> object as
192  * a <code>short</code> in the Java programming language.
193  *
194  * @param columnIndex the first column is 1, the second is 2, ...
195  * @return the column value; if the value is SQL <code>NULL</code>, the
196  * value returned is <code>0</code>
197  * @exception SQLException if a database access error occurs
198  */

199 public short getShort(int columnIndex) throws SQLException {
200   String JavaDoc str = getString(columnIndex);
201   return (str == null) ? 0 : Short.parseShort(str);
202 }
203
204 /**
205  * Gets the value of the designated column in the current row
206  * of this <code>ResultSet</code> object as
207  * an <code>int</code> in the Java programming language.
208  *
209  * @param columnIndex the first column is 1, the second is 2, ...
210  * @return the column value; if the value is SQL <code>NULL</code>, the
211  * value returned is <code>0</code>
212  * @exception SQLException if a database access error occurs
213  */

214 public int getInt(int columnIndex) throws SQLException {
215   String JavaDoc str = getString(columnIndex);
216   return (str == null) ? 0 : Integer.parseInt(str);
217 }
218
219 /**
220  * Retrieves the value of the designated column in the current row
221  * of this <code>ResultSet</code> object as
222  * a <code>long</code> in the Java programming language.
223  *
224  * @param columnIndex the first column is 1, the second is 2, ...
225  * @return the column value; if the value is SQL <code>NULL</code>, the
226  * value returned is <code>0</code>
227  * @exception SQLException if a database access error occurs
228  */

229 public long getLong(int columnIndex) throws SQLException {
230   String JavaDoc str = getString(columnIndex);
231   return (str == null) ? 0L : Long.parseLong(str);
232 }
233
234 /**
235  * Gets the value of the designated column in the current row
236  * of this <code>ResultSet</code> object as
237  * a <code>float</code> in the Java programming language.
238  *
239  * @param columnIndex the first column is 1, the second is 2, ...
240  * @return the column value; if the value is SQL <code>NULL</code>, the
241  * value returned is <code>0</code>
242  * @exception SQLException if a database access error occurs
243  */

244 public float getFloat(int columnIndex) throws SQLException {
245   String JavaDoc str = getString(columnIndex);
246   return (str == null) ? 0F : Float.parseFloat(str);
247 }
248
249 /**
250  * Retrieves the value of the designated column in the current row
251  * of this <code>ResultSet</code> object as
252  * a <code>double</code> in the Java programming language.
253  *
254  * @param columnIndex the first column is 1, the second is 2, ...
255  * @return the column value; if the value is SQL <code>NULL</code>, the
256  * value returned is <code>0</code>
257  * @exception SQLException if a database access error occurs
258  */

259 public double getDouble(int columnIndex) throws SQLException {
260   String JavaDoc str = getString(columnIndex);
261   return (str == null) ? 0D : Double.parseDouble(str);
262 }
263
264 /**
265  * Retrieves the value of the designated column in the current row
266  * of this <code>ResultSet</code> object as
267  * a <code>java.sql.BigDecimal</code> in the Java programming language.
268  *
269  * @param columnIndex the first column is 1, the second is 2, ...
270  * @param scale the number of digits to the right of the decimal point
271  * @return the column value; if the value is SQL <code>NULL</code>, the
272  * value returned is <code>null</code>
273  * @exception SQLException if a database access error occurs
274  * @deprecated
275  */

276 public BigDecimal JavaDoc getBigDecimal(int columnIndex, int scale)
277     throws SQLException {
278   // let getBigDecimal(int) handle this for now
279
return getBigDecimal(columnIndex);
280 }
281
282 /**
283  * Retrieves the value of the designated column in the current row
284  * of this <code>ResultSet</code> object as
285  * a <code>byte</code> array in the Java programming language.
286  * The bytes represent the raw values returned by the driver.
287  *
288  * @param columnIndex the first column is 1, the second is 2, ...
289  * @return the column value; if the value is SQL <code>NULL</code>, the
290  * value returned is <code>null</code>
291  * @exception SQLException if a database access error occurs
292  */

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

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

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

338 public Timestamp getTimestamp(int columnIndex) throws SQLException {
339   String JavaDoc str = getString(columnIndex);
340   return (str == null) ? null : Timestamp.valueOf(str);
341 }
342
343 /**
344  * Retrieves the value of the designated column in the current row
345  * of this <code>ResultSet</code> object as a stream of ASCII characters.
346  * The value can then be read in chunks from the stream. This method is
347  * particularly suitable for retrieving large <char>LONGVARCHAR</char>
348  * values. The JDBC driver will do any necessary conversion from the
349  * database format into ASCII.
350  *
351  * <P><B>Note:</B> All the data in the returned stream must be
352  * read prior to getting the value of any other column. The next
353  * call to a getter method implicitly closes the stream. Also, a
354  * stream may return <code>0</code> when the method
355  * <code>InputStream.available</code>
356  * is called whether there is data available or not.
357  *
358  * @param columnIndex the first column is 1, the second is 2, ...
359  * @return a Java input stream that delivers the database column value
360  * as a stream of one-byte ASCII characters;
361  * if the value is SQL <code>NULL</code>, the
362  * value returned is <code>null</code>
363  * @exception SQLException if a database access error occurs
364  */

365 public InputStream JavaDoc getAsciiStream(int columnIndex) throws SQLException {
366   String JavaDoc str = getString(columnIndex);
367   is = new ByteArrayInputStream JavaDoc(str.getBytes());
368   return (str == null) ? null : is;
369 }
370
371 /**
372  * Retrieves the value of the designated column in the current row
373  * of this <code>ResultSet</code> object as
374  * as a stream of two-byte Unicode characters. The first byte is
375  * the high byte; the second byte is the low byte.
376  *
377  * The value can then be read in chunks from the
378  * stream. This method is particularly
379  * suitable for retrieving large <code>LONGVARCHAR</code>values. The
380  * JDBC driver will do any necessary conversion from the database
381  * format into Unicode.
382  *
383  * <P><B>Note:</B> All the data in the returned stream must be
384  * read prior to getting the value of any other column. The next
385  * call to a getter method implicitly closes the stream.
386  * Also, a stream may return <code>0</code> when the method
387  * <code>InputStream.available</code>
388  * is called, whether there is data available or not.
389  *
390  * @param columnIndex the first column is 1, the second is 2, ...
391  * @return a Java input stream that delivers the database column value
392  * as a stream of two-byte Unicode characters;
393  * if the value is SQL <code>NULL</code>, the value returned is
394  * <code>null</code>
395  *
396  * @exception SQLException if a database access error occurs
397  * @deprecated use <code>getCharacterStream</code> in place of
398  * <code>getUnicodeStream</code>
399  */

400 public InputStream JavaDoc getUnicodeStream(int columnIndex) throws SQLException {
401   // delegate to getAsciiStream(int)
402
return getAsciiStream(columnIndex);
403 }
404
405 /**
406  * Retrieves the value of the designated column in the current row
407  * of this <code>ResultSet</code> object as a binary stream of
408  * uninterpreted bytes. The value can then be read in chunks from the
409  * stream. This method is particularly
410  * suitable for retrieving large <code>LONGVARBINARY</code> values.
411  *
412  * <P><B>Note:</B> All the data in the returned stream must be
413  * read prior to getting the value of any other column. The next
414  * call to a getter method implicitly closes the stream. Also, a
415  * stream may return <code>0</code> when the method
416  * <code>InputStream.available</code>
417  * is called whether there is data available or not.
418  *
419  * @param columnIndex the first column is 1, the second is 2, ...
420  * @return a Java input stream that delivers the database column value
421  * as a stream of uninterpreted bytes;
422  * if the value is SQL <code>NULL</code>, the value returned is
423  * <code>null</code>
424  * @exception SQLException if a database access error occurs
425  */

426 public InputStream JavaDoc getBinaryStream(int columnIndex) throws SQLException {
427   // delegate to getAsciiStream(int)
428
return getAsciiStream(columnIndex);
429 }
430
431 //======================================================================
432
// Methods for accessing results by column name
433
//======================================================================
434

435 /**
436  * Retrieves the value of the designated column in the current row
437  * of this <code>ResultSet</code> object as
438  * a <code>String</code> in the Java programming language.
439  *
440  * @param columnName the SQL name of the column
441  * @return the column value; if the value is SQL <code>NULL</code>, the
442  * value returned is <code>null</code>
443  * @exception SQLException if a database access error occurs
444  */

445 public String JavaDoc getString(String JavaDoc columnName) throws SQLException {
446   int colIndex = -1;
447   for( int i = 0; i < this.columnNames.length; i++ ) {
448     if(columnName.equalsIgnoreCase( this.columnNames[i] ))
449       colIndex = i;
450   }
451   if( colIndex == -1 )
452     throw new SQLException("Column "+columnName+" not found.");
453   return this.columnValues[colIndex];
454 }
455
456 /**
457  * Retrieves the value of the designated column in the current row
458  * of this <code>ResultSet</code> object as
459  * a <code>boolean</code> in the Java programming language.
460  *
461  * @param columnName the SQL name of the column
462  * @return the column value; if the value is SQL <code>NULL</code>, the
463  * value returned is <code>false</code>
464  * @exception SQLException if a database access error occurs
465  */

466 public boolean getBoolean(String JavaDoc columnName) throws SQLException {
467   String JavaDoc str = getString(columnName);
468   return (str == null) ? false : Boolean.valueOf(str).booleanValue();
469 }
470
471 /**
472  * Retrieves the value of the designated column in the current row
473  * of this <code>ResultSet</code> object as
474  * a <code>byte</code> in the Java programming language.
475  *
476  * @param columnName the SQL name of the column
477  * @return the column value; if the value is SQL <code>NULL</code>, the
478  * value returned is <code>0</code>
479  * @exception SQLException if a database access error occurs
480  */

481 public byte getByte(String JavaDoc columnName) throws SQLException {
482   String JavaDoc str = getString(columnName);
483   return (str == null) ? 0 : Byte.parseByte(str);
484 }
485
486 /**
487  * Retrieves the value of the designated column in the current row
488  * of this <code>ResultSet</code> object as
489  * a <code>short</code> in the Java programming language.
490  *
491  * @param columnName the SQL name of the column
492  * @return the column value; if the value is SQL <code>NULL</code>, the
493  * value returned is <code>0</code>
494  * @exception SQLException if a database access error occurs
495  */

496 public short getShort(String JavaDoc columnName) throws SQLException {
497   String JavaDoc str = getString(columnName);
498   return (str == null) ? 0 : Short.parseShort(str);
499 }
500
501 /**
502  * Gets the value of the designated column in the current row
503  * of this <code>ResultSet</code> object as
504  * an <code>int</code> in the Java programming language.
505  *
506  * @param columnName the SQL name of the column
507  * @return the column value; if the value is SQL <code>NULL</code>, the
508  * value returned is <code>0</code>
509  * @exception SQLException if a database access error occurs
510  */

511 public int getInt(String JavaDoc columnName) throws SQLException {
512   String JavaDoc str = getString(columnName);
513   return (str == null) ? 0 : Integer.parseInt(str);
514 }
515
516 /**
517  * Retrieves the value of the designated column in the current row
518  * of this <code>ResultSet</code> object as
519  * a <code>long</code> in the Java programming language.
520  *
521  * @param columnName the SQL name of the column
522  * @return the column value; if the value is SQL <code>NULL</code>, the
523  * value returned is <code>0</code>
524  * @exception SQLException if a database access error occurs
525  */

526 public long getLong(String JavaDoc columnName) throws SQLException {
527   String JavaDoc str = getString(columnName);
528   return (str == null) ? 0L : Long.parseLong(str);
529 }
530
531 /**
532  * Gets the value of the designated column in the current row
533  * of this <code>ResultSet</code> object as
534  * a <code>float</code> in the Java programming language.
535  *
536  * @param columnName the SQL name of the column
537  * @return the column value; if the value is SQL <code>NULL</code>, the
538  * value returned is <code>0</code>
539  * @exception SQLException if a database access error occurs
540  */

541 public float getFloat(String JavaDoc columnName) throws SQLException {
542   String JavaDoc str = getString(columnName);
543   return (str == null) ? 0F : Float.parseFloat(str);
544 }
545
546 /**
547  * Retrieves the value of the designated column in the current row
548  * of this <code>ResultSet</code> object as
549  * a <code>double</code> in the Java programming language.
550  *
551  * @param columnName the SQL name of the column
552  * @return the column value; if the value is SQL <code>NULL</code>, the
553  * value returned is <code>0</code>
554  * @exception SQLException if a database access error occurs
555  */

556 public double getDouble(String JavaDoc columnName) throws SQLException {
557   String JavaDoc str = getString(columnName);
558   return (str == null) ? 0D : Double.parseDouble(str);
559 }
560
561 /**
562  * Retrieves the value of the designated column in the current row
563  * of this <code>ResultSet</code> object as
564  * a <code>java.math.BigDecimal</code> in the Java programming language.
565  *
566  * @param columnName the SQL name of the column
567  * @param scale the number of digits to the right of the decimal point
568  * @return the column value; if the value is SQL <code>NULL</code>, the
569  * value returned is <code>null</code>
570  * @exception SQLException if a database access error occurs
571  * @deprecated
572  */

573 public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName, int scale)
574     throws SQLException {
575   // let getBigDecimal(String) handle this for now
576
return getBigDecimal(columnName);
577 }
578
579 /**
580  * Retrieves the value of the designated column in the current row
581  * of this <code>ResultSet</code> object as
582  * a <code>byte</code> array in the Java programming language.
583  * The bytes represent the raw values returned by the driver.
584  *
585  * @param columnName the SQL name of the column
586  * @return the column value; if the value is SQL <code>NULL</code>, the
587  * value returned is <code>null</code>
588  * @exception SQLException if a database access error occurs
589  */

590 public byte[] getBytes(String JavaDoc columnName) throws SQLException {
591   String JavaDoc str = getString(columnName);
592   return (str == null) ? null : str.getBytes();
593 }
594
595 /**
596  * Retrieves the value of the designated column in the current row
597  * of this <code>ResultSet</code> object as
598  * a <code>java.sql.Date</code> object in the Java programming language.
599  *
600  * @param columnName the SQL name of the column
601  * @return the column value; if the value is SQL <code>NULL</code>, the
602  * value returned is <code>null</code>
603  * @exception SQLException if a database access error occurs
604  */

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

621 public Time getTime(String JavaDoc columnName) throws SQLException {
622   String JavaDoc str = getString(columnName);
623   return (str == null) ? null : Time.valueOf(str);
624 }
625
626 /**
627  * Retrieves the value of the designated column in the current row
628  * of this <code>ResultSet</code> object as
629  * a <code>java.sql.Timestamp</code> object.
630  *
631  * @param columnName the SQL name of the column
632  * @return the column value; if the value is SQL <code>NULL</code>, the
633  * value returned is <code>null</code>
634  * @exception SQLException if a database access error occurs
635  */

636 public Timestamp getTimestamp(String JavaDoc columnName) throws SQLException {
637   String JavaDoc str = getString(columnName);
638   return (str == null) ? null : Timestamp.valueOf(str);
639 }
640
641 /**
642  * Retrieves the value of the designated column in the current row
643  * of this <code>ResultSet</code> object as a stream of
644  * ASCII characters. The value can then be read in chunks from the
645  * stream. This method is particularly
646  * suitable for retrieving large <code>LONGVARCHAR</code> values.
647  * The JDBC driver will
648  * do any necessary conversion from the database format into ASCII.
649  *
650  * <P><B>Note:</B> All the data in the returned stream must be
651  * read prior to getting the value of any other column. The next
652  * call to a getter method implicitly closes the stream. Also, a
653  * stream may return <code>0</code> when the method <code>available</code>
654  * is called whether there is data available or not.
655  *
656  * @param columnName the SQL name of the column
657  * @return a Java input stream that delivers the database column value
658  * as a stream of one-byte ASCII characters.
659  * If the value is SQL <code>NULL</code>,
660  * the value returned is <code>null</code>.
661  * @exception SQLException if a database access error occurs
662  */

663 public InputStream JavaDoc getAsciiStream(String JavaDoc columnName) throws SQLException {
664   String JavaDoc str = getString(columnName);
665   is = new ByteArrayInputStream JavaDoc(str.getBytes());
666   return (str == null) ? null : is;
667 }
668
669 /**
670  * Retrieves the value of the designated column in the current row
671  * of this <code>ResultSet</code> object as a stream of two-byte
672  * Unicode characters. The first byte is the high byte; the second
673  * byte is the low byte.
674  *
675  * The value can then be read in chunks from the
676  * stream. This method is particularly
677  * suitable for retrieving large <code>LONGVARCHAR</code> values.
678  * The JDBC technology-enabled driver will
679  * do any necessary conversion from the database format into Unicode.
680  *
681  * <P><B>Note:</B> All the data in the returned stream must be
682  * read prior to getting the value of any other column. The next
683  * call to a getter method implicitly closes the stream.
684  * Also, a stream may return <code>0</code> when the method
685  * <code>InputStream.available</code> is called, whether there
686  * is data available or not.
687  *
688  * @param columnName the SQL name of the column
689  * @return a Java input stream that delivers the database column value
690  * as a stream of two-byte Unicode characters.
691  * If the value is SQL <code>NULL</code>, the value returned
692  * is <code>null</code>.
693  * @exception SQLException if a database access error occurs
694  * @deprecated use <code>getCharacterStream</code> instead
695  */

696 public InputStream JavaDoc getUnicodeStream(String JavaDoc columnName) throws SQLException {
697   // delegate to getAsciiStream(String)
698
return getAsciiStream(columnName);
699 }
700
701 /**
702  * Retrieves the value of the designated column in the current row
703  * of this <code>ResultSet</code> object as a stream of uninterpreted
704  * <code>byte</code>s.
705  * The value can then be read in chunks from the
706  * stream. This method is particularly
707  * suitable for retrieving large <code>LONGVARBINARY</code>
708  * values.
709  *
710  * <P><B>Note:</B> All the data in the returned stream must be
711  * read prior to getting the value of any other column. The next
712  * call to a getter method implicitly closes the stream. Also, a
713  * stream may return <code>0</code> when the method <code>available</code>
714  * is called whether there is data available or not.
715  *
716  * @param columnName the SQL name of the column
717  * @return a Java input stream that delivers the database column value
718  * as a stream of uninterpreted bytes;
719  * if the value is SQL <code>NULL</code>, the result is <code>null</code>
720  * @exception SQLException if a database access error occurs
721  */

722 public InputStream JavaDoc getBinaryStream(String JavaDoc columnName) throws SQLException {
723   // delegate to getAsciiStream(String)
724
return getAsciiStream(columnName);
725 }
726
727 //=====================================================================
728
// Advanced features:
729
//=====================================================================
730

731 /**
732  * Retrieves the first warning reported by calls on this
733  * <code>ResultSet</code> object.
734  * Subsequent warnings on this <code>ResultSet</code> object
735  * will be chained to the <code>SQLWarning</code> object that
736  * this method returns.
737  *
738  * <P>The warning chain is automatically cleared each time a new
739  * row is read. This method may not be called on a <code>ResultSet</code>
740  * object that has been closed; doing so will cause an
741  * <code>SQLException</code> to be thrown.
742  * <P>
743  * <B>Note:</B> This warning chain only covers warnings caused
744  * by <code>ResultSet</code> methods. Any warning caused by
745  * <code>Statement</code> methods
746  * (such as reading OUT parameters) will be chained on the
747  * <code>Statement</code> object.
748  *
749  * @return the first <code>SQLWarning</code> object reported or
750  * <code>null</code> if there are none
751  * @exception SQLException if a database access error occurs or this method
752  * is called on a closed result set
753  */

754 public SQLWarning getWarnings() throws SQLException {
755   throw new UnsupportedOperationException JavaDoc(
756       "ResultSet.getWarnings() unsupported");
757 }
758
759 /**
760  * Clears all warnings reported on this <code>ResultSet</code> object.
761  * After this method is called, the method <code>getWarnings</code>
762  * returns <code>null</code> until a new warning is
763  * reported for this <code>ResultSet</code> object.
764  *
765  * @exception SQLException if a database access error occurs
766  */

767 public void clearWarnings() throws SQLException {
768   throw new UnsupportedOperationException JavaDoc(
769       "ResultSet.clearWarnings() unsupported");
770 }
771
772 /**
773  * Retrieves the name of the SQL cursor used by this <code>ResultSet</code>
774  * object.
775  *
776  * <P>In SQL, a result table is retrieved through a cursor that is
777  * named. The current row of a result set can be updated or deleted
778  * using a positioned update/delete statement that references the
779  * cursor name. To insure that the cursor has the proper isolation
780  * level to support update, the cursor's <code>SELECT</code> statement
781  * should be of the form <code>SELECT FOR UPDATE</code>. If
782  * <code>FOR UPDATE</code> is omitted, the positioned updates may fail.
783  *
784  * <P>The JDBC API supports this SQL feature by providing the name of the
785  * SQL cursor used by a <code>ResultSet</code> object.
786  * The current row of a <code>ResultSet</code> object
787  * is also the current row of this SQL cursor.
788  *
789  * <P><B>Note:</B> If positioned update is not supported, a
790  * <code>SQLException</code> is thrown.
791  *
792  * @return the SQL name for this <code>ResultSet</code> object's cursor
793  * @exception SQLException if a database access error occurs
794  */

795 public String JavaDoc getCursorName() throws SQLException {
796   throw new UnsupportedOperationException JavaDoc(
797       "ResultSet.getCursorName() unsupported");
798 }
799
800 /**
801  * Retrieves the number, types and properties of
802  * this <code>ResultSet</code> object's columns.
803  *
804  * @return the description of this <code>ResultSet</code> object's columns
805  * @exception SQLException if a database access error occurs
806  */

807 public ResultSetMetaData getMetaData() throws SQLException {
808   if (resultSetMetaData == null) {
809     resultSetMetaData = new XmlResultSetMetaData(tableName, columnNames);
810   }
811   return resultSetMetaData;
812
813 }
814
815 /**
816  * <p>Gets the value of the designated column in the current row
817  * of this <code>ResultSet</code> object as
818  * an <code>Object</code> in the Java programming language.
819  *
820  * <p>This method will return the value of the given column as a
821  * Java object. The type of the Java object will be the default
822  * Java object type corresponding to the column's SQL type,
823  * following the mapping for built-in types specified in the JDBC
824  * specification. If the value is an SQL <code>NULL</code>,
825  * the driver returns a Java <code>null</code>.
826  *
827  * <p>This method may also be used to read datatabase-specific
828  * abstract data types.
829  *
830  * In the JDBC 2.0 API, the behavior of method
831  * <code>getObject</code> is extended to materialize
832  * data of SQL user-defined types. When a column contains
833  * a structured or distinct value, the behavior of this method is as
834  * if it were a call to: <code>getObject(columnIndex,
835  * this.getStatement().getConnection().getTypeMap())</code>.
836  *
837  * @param columnIndex the first column is 1, the second is 2, ...
838  * @return a <code>java.lang.Object</code> holding the column value
839  * @exception SQLException if a database access error occurs
840  */

841 public Object JavaDoc getObject(int columnIndex) throws SQLException {
842 // throw new UnsupportedOperationException(
843
// "ResultSet.getObject(int) unsupported");
844
return getString(columnIndex);
845 }
846 /**
847  * <p>Gets the value of the designated column in the current row
848  * of this <code>ResultSet</code> object as
849  * an <code>Object</code> in the Java programming language.
850  *
851  * <p>This method will return the value of the given column as a
852  * Java object. The type of the Java object will be the default
853  * Java object type corresponding to the column's SQL type,
854  * following the mapping for built-in types specified in the JDBC
855  * specification. If the value is an SQL <code>NULL</code>,
856  * the driver returns a Java <code>null</code>.
857  * <P>
858  * This method may also be used to read datatabase-specific
859  * abstract data types.
860  * <P>
861  * In the JDBC 2.0 API, the behavior of the method
862  * <code>getObject</code> is extended to materialize
863  * data of SQL user-defined types. When a column contains
864  * a structured or distinct value, the behavior of this method is as
865  * if it were a call to: <code>getObject(columnIndex,
866  * this.getStatement().getConnection().getTypeMap())</code>.
867  *
868  * @param columnName the SQL name of the column
869  * @return a <code>java.lang.Object</code> holding the column value
870  * @exception SQLException if a database access error occurs
871  */

872 public Object JavaDoc getObject(String JavaDoc columnName) throws SQLException {
873 // throw new UnsupportedOperationException(
874
// "ResultSet.getObject(String) unsupported");
875
return getString(columnName);
876 }
877
878 /**
879  * Maps the given <code>ResultSet</code> column name to its
880  * <code>ResultSet</code> column index.
881  *
882  * @param columnName the name of the column
883  * @return the column index of the given column name
884  * @exception SQLException if the <code>ResultSet</code> object does
885  * not contain <code>columnName</code> or a database access error occurs
886  */

887 public int findColumn(String JavaDoc columnName) throws SQLException {
888   throw new UnsupportedOperationException JavaDoc(
889       "ResultSet.findColumn(String) unsupported");
890 }
891
892 //--------------------------JDBC 2.0-----------------------------------
893

894 //---------------------------------------------------------------------
895
// Getters and Setters
896
//---------------------------------------------------------------------
897

898 /**
899  * Retrieves the value of the designated column in the current row
900  * of this <code>ResultSet</code> object as a
901  * <code>java.io.Reader</code> object.
902  *
903  * @param columnIndex the first column is 1, the second is 2, ...
904  * @return a <code>java.io.Reader</code> object that contains the column
905  * value; if the value is SQL <code>NULL</code>, the value returned is
906  * <code>null</code> in the Java programming language.
907  * @exception SQLException if a database access error occurs
908  */

909 public Reader JavaDoc getCharacterStream(int columnIndex) throws SQLException {
910   String JavaDoc str = getString(columnIndex);
911   return (str == null) ? null : new StringReader JavaDoc(str);
912 }
913
914 /**
915  * Retrieves the value of the designated column in the current row
916  * of this <code>ResultSet</code> object as a
917  * <code>java.io.Reader</code> object.
918  *
919  * @param columnName the name of the column
920  * @return a <code>java.io.Reader</code> object that contains the column
921  * value; if the value is SQL <code>NULL</code>, the value returned is
922  * <code>null</code> in the Java programming language
923  * @exception SQLException if a database access error occurs
924  */

925 public Reader JavaDoc getCharacterStream(String JavaDoc columnName) throws SQLException {
926   String JavaDoc str = getString(columnName);
927   return (str == null) ? null : new StringReader JavaDoc(str);
928 }
929
930 /**
931  * Retrieves the value of the designated column in the current row
932  * of this <code>ResultSet</code> object as a
933  * <code>java.math.BigDecimal</code> with full precision.
934  *
935  * @param columnIndex the first column is 1, the second is 2, ...
936  * @return the column value (full precision);
937  * if the value is SQL <code>NULL</code>, the value returned is
938  * <code>null</code> in the Java programming language.
939  * @exception SQLException if a database access error occurs
940  */

941 public BigDecimal JavaDoc getBigDecimal(int columnIndex) throws SQLException {
942   BigDecimal JavaDoc retval = null;
943   String JavaDoc str = getString(columnIndex);
944   if(str != null) {
945     try {
946       retval = new BigDecimal JavaDoc(str);
947     }
948     catch (NumberFormatException JavaDoc e) {
949       throw new SQLException("Could not convert '" + str + "' to " +
950                              "a java.math.BigDecimal object");
951     }
952   }
953   return retval;
954 }
955
956 /**
957  * Retrieves the value of the designated column in the current row
958  * of this <code>ResultSet</code> object as a
959  * <code>java.math.BigDecimal</code> with full precision.
960  *
961  * @param columnName the column name
962  * @return the column value (full precision);
963  * if the value is SQL <code>NULL</code>, the value returned is
964  * <code>null</code> in the Java programming language.
965  * @exception SQLException if a database access error occurs
966  */

967 public BigDecimal JavaDoc getBigDecimal(String JavaDoc columnName) throws SQLException {
968   BigDecimal JavaDoc retval = null;
969   String JavaDoc str = getString(columnName);
970   if(str != null) {
971     try {
972       retval = new BigDecimal JavaDoc(str);
973     }
974     catch (NumberFormatException JavaDoc e) {
975       throw new SQLException("Could not convert '" + str + "' to " +
976                              "a java.math.BigDecimal object");
977     }
978   }
979   return retval;
980 }
981
982 //---------------------------------------------------------------------
983
// Traversal/Positioning
984
//---------------------------------------------------------------------
985

986 /**
987  * Retrieves whether the cursor is before the first row in
988  * this <code>ResultSet</code> object.
989  *
990  * @return <code>true</code> if the cursor is before the first row;
991  * <code>false</code> if the cursor is at any other position or the
992  * result set contains no rows
993  * @exception SQLException if a database access error occurs
994  */

995 public boolean isBeforeFirst() throws SQLException {
996   throw new UnsupportedOperationException JavaDoc(
997       "ResultSet.isBeforeFirst() unsupported");
998 }
999
1000/**
1001 * Retrieves whether the cursor is after the last row in
1002 * this <code>ResultSet</code> object.
1003 *
1004 * @return <code>true</code> if the cursor is after the last row;
1005 * <code>false</code> if the cursor is at any other position or the
1006 * result set contains no rows
1007 * @exception SQLException if a database access error occurs
1008 */

1009public boolean isAfterLast() throws SQLException {
1010  throw new UnsupportedOperationException JavaDoc(
1011      "ResultSet.isAfterLast() unsupported");
1012}
1013
1014/**
1015 * Retrieves whether the cursor is on the first row of
1016 * this <code>ResultSet</code> object.
1017 *
1018 * @return <code>true</code> if the cursor is on the first row;
1019 * <code>false</code> otherwise
1020 * @exception SQLException if a database access error occurs
1021 */

1022public boolean isFirst() throws SQLException {
1023  throw new UnsupportedOperationException JavaDoc(
1024      "ResultSet.isFirst() unsupported");
1025}
1026
1027/**
1028 * Retrieves whether the cursor is on the last row of
1029 * this <code>ResultSet</code> object.
1030 * Note: Calling the method <code>isLast</code> may be expensive
1031 * because the JDBC driver
1032 * might need to fetch ahead one row in order to determine
1033 * whether the current row is the last row in the result set.
1034 *
1035 * @return <code>true</code> if the cursor is on the last row;
1036 * <code>false</code> otherwise
1037 * @exception SQLException if a database access error occurs
1038 */

1039public boolean isLast() throws SQLException {
1040  throw new UnsupportedOperationException JavaDoc(
1041      "ResultSet.isLast() unsupported");
1042}
1043
1044/**
1045 * Moves the cursor to the front of
1046 * this <code>ResultSet</code> object, just before the
1047 * first row. This method has no effect i