KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nqadmin > swingSet > datasources > SSJdbcRowSetImpl


1 /* $Id: SSJdbcRowSetImpl.java,v 1.13 2005/02/12 03:27:09 yoda2 Exp $
2  *
3  * Tab Spacing = 4
4  *
5  * Copyright (c) 2004-2005, The Pangburn Company and Prasanth R. Pasala
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer. Redistributions in binary
13  * form must reproduce the above copyright notice, this list of conditions and
14  * the following disclaimer in the documentation and/or other materials
15  * provided with the distribution. The names of its contributors may not be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  */

32
33 package com.nqadmin.swingSet.datasources;
34
35 import java.sql.SQLException JavaDoc;
36 import java.sql.Connection JavaDoc;
37 import java.sql.ResultSet JavaDoc;
38 import java.sql.ResultSetMetaData JavaDoc;
39 import java.io.ObjectInputStream JavaDoc;
40 import java.io.IOException JavaDoc;
41 import java.sql.Date JavaDoc;
42 import javax.sql.RowSetListener JavaDoc;
43 import com.sun.rowset.JdbcRowSetImpl;
44 import java.beans.PropertyChangeSupport JavaDoc;
45 import java.beans.PropertyChangeListener JavaDoc;
46 import java.beans.VetoableChangeSupport JavaDoc;
47 import java.beans.VetoableChangeListener JavaDoc;
48 import java.beans.PropertyVetoException JavaDoc;
49
50 /**
51  * SSJdbcRowSetImpl.java
52  *<p>
53  * SwingSet - Open Toolkit For Making Swing Controls Database-Aware
54  *<p><pre>
55  * The SSJdbcRowSetImpl class is a wrapper for JdbcRowSetImpl.
56  * It provides all rowset-related functionality for linking SwingSet components
57  * to an SSConnection.
58  * @author $Author: yoda2 $
59  * @version $Revision: 1.13 $
60  */

61  public class SSJdbcRowSetImpl extends SSRowSetAdapter {
62
63     /**
64      * SSConnection used to populate SSRowSet.
65      */

66     protected SSConnection sSConnection = new SSConnection();
67
68     /**
69      * Query used to populate SSRowSet.
70      */

71     protected String JavaDoc command = "";
72
73     /**
74      * JDBC connection wrapped by SSConnection.
75      */

76     transient protected Connection JavaDoc connection;
77
78     /**
79      * Instance of JdbcRowSetImpl wrapped by SSJdbcRowSetImpl.
80      */

81     transient protected JdbcRowSetImpl rowset;
82
83     /**
84      * Metadata for query.
85      */

86     transient protected ResultSetMetaData JavaDoc metaData;
87
88     /**
89      * Convenience class for providing the property change listener support
90      */

91     private PropertyChangeSupport JavaDoc pChangeSupport = new PropertyChangeSupport JavaDoc(this);
92
93     /**
94      * Convenience class for providing the vetoable change listener support
95      */

96     private VetoableChangeSupport JavaDoc vChangeSupport = new VetoableChangeSupport JavaDoc(this);
97
98     /**
99      * Constructs a default SSJdbcRowSetImpl object.
100      */

101     public SSJdbcRowSetImpl(){
102     }
103
104     /**
105      * Constructs a SSJdbcRowSetImpl object with the specified SSConnection.
106      * @param _ssConnection SSConnection object to be used to connect to the database.
107      */

108     public SSJdbcRowSetImpl(SSConnection _ssConnection) {
109         sSConnection = _ssConnection;
110     }
111
112     /**
113      * Constructs a SSJdbcRowSetImpl object with the specified SSConnection & command.
114      * @param _ssConnection SSConnection object to be used to connect to the database.
115      * @param _command SQL query to be executed.
116      */

117     public SSJdbcRowSetImpl(SSConnection _ssConnection, String JavaDoc _command) {
118         sSConnection = _ssConnection;
119         command = _command;
120     }
121
122     /**
123      * Method to add bean property change listeners.
124      *
125      * @param _listener bean property change listener
126      */

127     public void addPropertyChangeListener(PropertyChangeListener JavaDoc _listener) {
128         pChangeSupport.addPropertyChangeListener(_listener);
129     }
130
131     /**
132      * Method to remove bean property change listeners.
133      *
134      * @param _listener bean property change listener
135      */

136     public void removePropertyChangeListener(PropertyChangeListener JavaDoc _listener) {
137         pChangeSupport.removePropertyChangeListener(_listener);
138     }
139
140     /**
141      * Method to add bean vetoable change listeners.
142      *
143      * @param _listener bean vetoable change listener
144      */

145     public void addVetoableChangeListener(VetoableChangeListener JavaDoc _listener) {
146         vChangeSupport.addVetoableChangeListener(_listener);
147     }
148
149     /**
150      * Method to remove bean veto change listeners.
151      *
152      * @param _listener bean veto change listener
153      */

154     public void removeVetoableChangeListener(VetoableChangeListener JavaDoc _listener) {
155         vChangeSupport.removeVetoableChangeListener(_listener);
156     }
157
158     /**
159      * Sets the connection object to be used.
160      * @param _ssConnection connection object to be used to connect to the database.
161      */

162     public void setSSConnection(SSConnection _ssConnection) {
163         SSConnection oldValue = sSConnection;
164         sSConnection = _ssConnection;
165         pChangeSupport.firePropertyChange("ssConnection", oldValue, sSConnection);
166     }
167
168     /**
169      * Sets the command for the rowset.
170      * @param _command query to be executed.
171      */

172     public void setCommand(String JavaDoc _command) {
173         String JavaDoc oldValue = command;
174         command = _command;
175         pChangeSupport.firePropertyChange("command", oldValue, command);
176
177         try {
178             if (rowset != null) {
179                 rowset.setCommand(command);
180             }
181         }catch(SQLException JavaDoc se){
182             se.printStackTrace();
183         }
184     }
185
186     /**
187      * Returns the SSConnection object being used.
188      * @return returns the SSConnection object being used.
189      */

190     public SSConnection getSSConnection(){
191         return sSConnection;
192     }
193
194     /**
195      * Returns the query being used.
196      * @return returns the query being used.
197      */

198     public String JavaDoc getCommand(){
199         return command;
200     }
201
202     /**
203      * Fills this RowSet object with data.
204      * If the required properties have not been set, an exception is thrown. If this
205      * method is successful, the current contents of the rowset are discarded. If there
206      * are outstanding updates, they are ignored.
207      * @throws SQLException - if a data access error occurs or any of the properties necessary
208      * for making a connection have not been set
209      */

210     public void execute() throws SQLException JavaDoc{
211         if(rowset == null){
212             rowset = new JdbcRowSetImpl(sSConnection.getConnection());
213             rowset.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
214             rowset.setConcurrency(ResultSet.CONCUR_UPDATABLE);
215             rowset.setCommand(command);
216         }
217         rowset.execute();
218         metaData = rowset.getMetaData();
219     }
220
221     /**
222      * Recreates the rowset object during the deserialization process.
223      */

224     protected void readObject(ObjectInputStream JavaDoc inStream) throws ClassNotFoundException JavaDoc, IOException JavaDoc{
225         inStream.defaultReadObject();
226     // GET THE CONNECTION OBJECT FROM THE SSCONNECTION.
227
connection = sSConnection.getConnection();
228         try{
229         // CREATE NEW INSTANCE OF JDBC ROWSET.
230
rowset = new JdbcRowSetImpl(connection);
231             rowset.setType(ResultSet.TYPE_SCROLL_INSENSITIVE);
232             rowset.setConcurrency(ResultSet.CONCUR_UPDATABLE);
233
234         // SET THE COMMAND FOR ROWSET
235
rowset.setCommand(command);
236
237         // CALL EXECUTE ONLY IF THE QUERY IS NOT EMPTY.
238
if(!command.equals("")){
239                 rowset.execute();
240                 metaData = rowset.getMetaData();
241             }
242         }catch(SQLException JavaDoc se){
243             se.printStackTrace();
244         }
245
246     }
247
248     /**
249      * Retrieves the value of the designated column in the current row of this DataSet
250      * object as a boolean in the Java programming language.
251      * @param columnIndex - column number . first column is 1, second column is 2....
252      * @return returns the column value of the current row, if the value is null then a false
253      * is returned.
254      * @throws throws an SQL exception if an access error occurs.
255      */

256     public boolean getBoolean(int columnIndex) throws SQLException JavaDoc{
257         return rowset.getBoolean(columnIndex);
258     }
259
260     /**
261      * Retrieves the value of the designated column in the current row of this DataSet
262      * object as a int in the Java programming language.
263      * @param columnIndex - column number . first column is 1, second column is 2....
264      * @return returns the column value of the current row, if the value is null then 0
265      * is returned.
266      * @throws throws an SQL exception if an access error occurs.
267      */

268     public int getInt(int columnIndex) throws SQLException JavaDoc{
269         return rowset.getInt(columnIndex);
270     }
271
272     /**
273      * Retrieves the value of the designated column in the current row of this DataSet
274      * object as a long in the Java programming language.
275      * @param columnIndex - column number . first column is 1, second column is 2....
276      * @return returns the column value of the current row, if the value is null then 0
277      * is returned.
278      * @throws throws an SQL exception if an access error occurs.
279      */

280     public long getLong(int columnIndex) throws SQLException JavaDoc{
281         return rowset.getLong(columnIndex);
282     }
283
284     /**
285      * Retrieves the value of the designated column in the current row of this DataSet
286      * object as a float in the Java programming language.
287      * @param columnIndex - column number . first column is 1, second column is 2....
288      * @return returns the column value of the current row, if the value is null then 0
289      * is returned.
290      * @throws throws an SQL exception if an access error occurs.
291      */

292     public float getFloat(int columnIndex) throws SQLException JavaDoc{
293         return rowset.getFloat(columnIndex);
294     }
295
296     /**
297      * Retrieves the value of the designated column in the current row of this DataSet
298      * object as a double in the Java programming language.
299      * @param columnIndex - column number . first column is 1, second column is 2....
300      * @return returns the column value of the current row, if the value is null then 0
301      * is returned.
302      * @throws throws an SQL exception if an access error occurs.
303      */

304     public double getDouble(int columnIndex) throws SQLException JavaDoc{
305         return rowset.getDouble(columnIndex);
306     }
307
308     /**
309      * Retrieves the value of the designated column in the current row of this DataSet
310      * object as a String in the Java programming language.
311      * @param columnIndex - column number . first column is 1, second column is 2....
312      * @return returns the column value of the current row, if the value is null then a null
313      * is returned.
314      * @throws throws an SQL exception if an access error occurs.
315      */

316     public String JavaDoc getString(int columnIndex) throws SQLException JavaDoc{
317         return rowset.getString(columnIndex);
318     }
319
320     /**
321      * Retrieves the value of the designated column in the current row of this DataSet
322      * object as a Date in the Java programming language.
323      * @param columnIndex - column number . first column is 1, second column is 2....
324      * @return returns the column value of the current row, if the value is null then null
325      * is returned.
326      * @throws throws an SQL exception if an access error occurs.
327      */

328     public Date JavaDoc getDate(int columnIndex) throws SQLException JavaDoc{
329         return rowset.getDate(columnIndex);
330     }
331
332     /**
333      * Retrieves the value of the designated column in the current row of this ResultSet
334      * object as a byte array in the Java programming language. The bytes represent the
335      * raw values returned by the driver.
336      * @param columnIndex - index number of the column
337      * @return returns the column value; if the value is SQL NULL, the value returned is null
338      * @throws throws an SQLException - if a database access error occurs
339      */

340     public byte[] getBytes(int columnIndex) throws SQLException JavaDoc {
341         return rowset.getBytes(columnIndex);
342     }
343
344     /**
345      * Updates the designated column with a boolean value. The updater methods are used to
346      * update column values in the current row or the insert row. The updater methods do
347      * not update the underlying data source; instead the updateRow or insertRow methods are called
348      * to update the underlying data source.
349      * @param columnIndex - index number of the column. first column is 1, second column is 2......
350      * @param value - new column value
351      * @throws throws an SQL exception if an access error occurs.
352      */

353     public void updateBoolean(int columnIndex, boolean value) throws SQLException JavaDoc{
354         rowset.updateBoolean(columnIndex, value);
355     }
356
357     /**
358      * Updates the designated column with a int value. The updater methods are used to
359      * update column values in the current row or the insert row. The updater methods do
360      * not update the underlying data source; instead the updateRow or insertRow methods are called
361      * to update the underlying data source.
362      * @param columnIndex - index number of the column. first column is 1, second column is 2......
363      * @param value - new column value
364      * @throws throws an SQL exception if an access error occurs.
365      */

366     public void updateInt(int columnIndex, int value) throws SQLException JavaDoc{
367         rowset.updateInt(columnIndex, value);
368     }
369
370     /**
371      * Updates the designated column with a long value. The updater methods are used to
372      * update column values in the current row or the insert row. The updater methods do
373      * not update the underlying data source; instead the updateRow or insertRow methods are called
374      * to update the underlying data source.
375      * @param columnIndex - index number of the column. first column is 1, second column is 2......
376      * @param value - new column value
377      * @throws throws an SQL exception if an access error occurs.
378      */

379     public void updateLong(int columnIndex, long value) throws SQLException JavaDoc{
380         rowset.updateLong(columnIndex, value);
381     }
382
383     /**
384      * Updates the designated column with a float value. The updater methods are used to
385      * update column values in the current row or the insert row. The updater methods do
386      * not update the underlying data source; instead the updateRow or insertRow methods are called
387      * to update the underlying data source.
388      * @param columnIndex - index number of the column. first column is 1, second column is 2......
389      * @param value - new column value
390      * @throws throws an SQL exception if an access error occurs.
391      */

392     public void updateFloat(int columnIndex, float value) throws SQLException JavaDoc{
393         rowset.updateFloat(columnIndex, value);
394     }
395
396     /**
397      * Updates the designated column with a double value. The updater methods are used to
398      * update column values in the current row or the insert row. The updater methods do
399      * not update the underlying data source; instead the updateRow or insertRow methods are called
400      * to update the underlying data source.
401      * @param columnIndex - index number of the column. first column is 1, second column is 2......
402      * @param value - new column value
403      * @throws throws an SQL exception if an access error occurs.
404      */

405     public void updateDouble(int columnIndex, double value) throws SQLException JavaDoc{
406         rowset.updateDouble(columnIndex, value);
407     }
408
409     /**
410      * Updates the designated column with a String value. The updater methods are used to
411      * update column values in the current row or the insert row. The updater methods do
412      * not update the underlying data source; instead the updateRow or insertRow methods are called
413      * to update the underlying data source.
414      * @param columnIndex - index number of the column. first column is 1, second column is 2......
415      * @param value - new column value
416      * @throws throws an SQL exception if an access error occurs.
417      */

418     public void updateString(int columnIndex, String JavaDoc value) throws SQLException JavaDoc{
419         rowset.updateString(columnIndex, value);
420     }
421
422     /**
423      * Updates the designated column with a Date value. The updater methods are used to
424      * update column values in the current row or the insert row. The updater methods do
425      * not update the underlying data source; instead the updateRow or insertRow methods are called
426      * to update the underlying data source.
427      * @param columnIndex - index number of the column. first column is 1, second column is 2......
428      * @param value - new column value
429      * @throws throws an SQL exception if an access error occurs.
430      */

431     public void updateDate(int columnIndex, Date JavaDoc value) throws SQLException JavaDoc{
432         rowset.updateDate(columnIndex, value);
433     }
434
435     /**
436      * Updates the designated column with a byte array value. The updater methods are
437      * used to update column values in the current row or the insert row. The updater
438      * methods do not update the underlying database; instead the updateRow or insertRow
439      * methods are called to update the database.
440      * @param columnIndex - the index number of the column
441      * @param value - the new column value
442      * @throws throws an SQLException - if a database access error occurs
443      */

444     public void updateBytes(int columnIndex, byte[] value) throws SQLException JavaDoc {
445         rowset.updateBytes(columnIndex, value);
446     }
447
448     /**
449      * Updates the designated column with a null value. The updater methods are used to
450      * update column values in the current row or the insert row. The updater methods do
451      * not update the underlying data source; instead the updateRow or insertRow methods are called
452      * to update the underlying data source.
453      * @param columnIndex - index number of the column. first column is 1, second column is 2......
454      * @throws throws an SQL exception if an access error occurs.
455      */

456     public void updateNull(int columnIndex) throws SQLException JavaDoc{
457         rowset.updateNull(columnIndex);
458     }
459
460     /**
461      * Retrieves the value of the designated column in the current row of this DataSet
462      * object as a boolean in the Java programming language.
463      * @param columnName - name of the column
464      * @return returns the column value of the current row, if the value is null then a false
465      * is returned.
466      * @throws throws an SQL exception if an access error occurs.
467      */

468     public boolean getBoolean(String JavaDoc columnName) throws SQLException JavaDoc{
469         return rowset.getBoolean(columnName);
470     }
471
472     /**
473      * Retrieves the value of the designated column in the current row of this DataSet
474      * object as a int in the Java programming language.
475      * @param columnName - name of the column
476      * @return returns the column value of the current row, if the value is null then 0
477      * is returned.
478      * @throws throws an SQL exception if an access error occurs.
479      */

480     public int getInt(String JavaDoc columnName) throws SQLException JavaDoc{
481         return rowset.getInt(columnName);
482     }
483
484     /**
485      * Retrieves the value of the designated column in the current row of this DataSet
486      * object as a long in the Java programming language.
487      * @param columnName - name of the column
488      * @return returns the column value of the current row, if the value is null then 0
489      * is returned.
490      * @throws throws an SQL exception if an access error occurs.
491      */

492     public long getLong(String JavaDoc columnName) throws SQLException JavaDoc{
493         return rowset.getLong(columnName);
494     }
495
496     /**
497      * Retrieves the value of the designated column in the current row of this DataSet
498      * object as a float in the Java programming language.
499      * @param columnName - name of the column
500      * @return returns the column value of the current row, if the value is null then 0
501      * is returned.
502      * @throws throws an SQL exception if an access error occurs.
503      */

504     public float getFloat(String JavaDoc columnName) throws SQLException JavaDoc{
505         return rowset.getFloat(columnName);
506     }
507
508     /**
509      * Retrieves the value of the designated column in the current row of this DataSet
510      * object as a double in the Java programming language.
511      * @param columnName - name of the column
512      * @return returns the column value of the current row, if the value is null then 0
513      * is returned.
514      * @throws throws an SQL exception if an access error occurs.
515      */

516     public double getDouble(String JavaDoc columnName) throws SQLException JavaDoc{
517         return rowset.getDouble(columnName);
518     }
519
520     /**
521      * Retrieves the value of the designated column in the current row of this DataSet
522      * object as a String in the Java programming language.
523      * @param columnName - name of the column
524      * @return returns the column value of the current row, if the value is null then a null
525      * is returned.
526      * @throws throws an SQL exception if an access error occurs.
527      */

528     public String JavaDoc getString(String JavaDoc columnName) throws SQLException JavaDoc{
529         return rowset.getString(columnName);
530     }
531
532     /**
533      * Retrieves the value of the designated column in the current row of this DataSet
534      * object as a Date in the Java programming language.
535      * @param columnName - name of the column
536      * @return returns the column value of the current row, if the value is null then a null
537      * is returned.
538      * @throws throws an SQL exception if an access error occurs.
539      */

540     public Date JavaDoc getDate(String JavaDoc columnName) throws SQLException JavaDoc{
541         return rowset.getDate(columnName);
542     }
543
544     /**
545      * Retrieves the value of the designated column in the current row of this ResultSet
546      * object as a byte array in the Java programming language. The bytes represent the
547      * raw values returned by the driver.
548      * @param columnName - the SQL name of the column
549      * @return returns the column value; if the value is SQL NULL, the value returned is null
550      * @throws throws an SQLException - if a database access error occurs
551      */

552     public byte[] getBytes(String JavaDoc columnName) throws SQLException JavaDoc {
553         return rowset.getBytes(columnName);
554     }
555
556     /**
557      * Updates the designated column with a boolean value. The updater methods are used to
558      * update column values in the current row or the insert row. The updater methods do
559      * not update the underlying data source; instead the updateRow or insertRow methods are called
560      * to update the underlying data source.
561      * @param columnName - name of the column
562      * @param value - new column value
563      * @throws throws an SQL exception if an access error occurs.
564      */

565     public void updateBoolean(String JavaDoc columnName, boolean value) throws SQLException JavaDoc{
566         rowset.updateBoolean(columnName, value);
567     }
568
569     /**
570      * Updates the designated column with a int value. The updater methods are used to
571      * update column values in the current row or the insert row. The updater methods do
572      * not update the underlying data source; instead the updateRow or insertRow methods are called
573      * to update the underlying data source.
574      * @param columnName - name of the column
575      * @param value - new column value
576      * @throws throws an SQL exception if an access error occurs.
577      */

578     public void updateInt(String JavaDoc columnName, int value) throws SQLException JavaDoc{
579         rowset.updateInt(columnName, value);
580     }
581
582     /**
583      * Updates the designated column with a long value. The updater methods are used to
584      * update column values in the current row or the insert row. The updater methods do
585      * not update the underlying data source; instead the updateRow or insertRow methods are called
586      * to update the underlying data source.
587      * @param columnName - name of the column
588      * @param value - new column value
589      * @throws throws an SQL exception if an access error occurs.
590      */

591     public void updateLong(String JavaDoc columnName, long value) throws SQLException JavaDoc{
592         rowset.updateLong(columnName, value);
593     }
594
595     /**
596      * Updates the designated column with a float value. The updater methods are used to
597      * update column values in the current row or the insert row. The updater methods do
598      * not update the underlying data source; instead the updateRow or insertRow methods are called
599      * to update the underlying data source.
600      * @param columnName - name of the column
601      * @param value - new column value
602      * @throws throws an SQL exception if an access error occurs.
603      */

604     public void updateFloat(String JavaDoc columnName, float value) throws SQLException JavaDoc{
605         rowset.updateFloat(columnName, value);
606     }
607
608     /**
609      * Updates the designated column with a double value. The updater methods are used to
610      * update column values in the current row or the insert row. The updater methods do
611      * not update the underlying data source; instead the updateRow or insertRow methods are called
612      * to update the underlying data source.
613      * @param columnName - name of the column
614      * @param value - new column value
615      * @throws throws an SQL exception if an access error occurs.
616      */

617     public void updateDouble(String JavaDoc columnName, double value) throws SQLException JavaDoc{
618         rowset.updateDouble(columnName, value);
619     }
620
621     /**
622      * Updates the designated column with a String value. The updater methods are used to
623      * update column values in the current row or the insert row. The updater methods do
624      * not update the underlying data source; instead the updateRow or insertRow methods are called
625      * to update the underlying data source.
626      * @param columnName - name of the column
627      * @param value - new column value
628      * @throws throws an SQL exception if an access error occurs.
629      */

630     public void updateString(String JavaDoc columnName, String JavaDoc value) throws SQLException JavaDoc{
631         rowset.updateString(columnName, value);
632     }
633
634     /**
635      * Updates the designated column with a Date value. The updater methods are used to
636      * update column values in the current row or the insert row. The updater methods do
637      * not update the underlying data source; instead the updateRow or insertRow methods are called
638      * to update the underlying data source.
639      * @param columnName - name of the column
640      * @param value - new column value
641      * @throws throws an SQL exception if an access error occurs.
642      */

643     public void updateDate(String JavaDoc columnName, Date JavaDoc value) throws SQLException JavaDoc{
644         rowset.updateDate(columnName, value);
645     }
646
647     /**
648      * Updates the designated column with a byte array value. The updater methods are
649      * used to update column values in the current row or the insert row. The updater
650      * methods do not update the underlying database; instead the updateRow or insertRow
651      * methods are called to update the database.
652      * @param columnName - the name of the column
653      * @param value - the new column value
654      * @throws throws an SQLException - if a database access error occurs
655      */

656     public void updateBytes(String JavaDoc columnName, byte[] value) throws SQLException JavaDoc {
657         rowset.updateBytes(columnName, value);
658     }
659
660     /**
661      * Updates the designated column with a null value. The updater methods are used to
662      * update column values in the current row or the insert row. The updater methods do
663      * not update the underlying data source; instead the updateRow or insertRow methods are called
664      * to update the underlying data source.
665      * @param columnName - name of the column
666      * @throws throws an SQL exception if an access error occurs.
667      */

668     public void updateNull(String JavaDoc columnName) throws SQLException JavaDoc{
669         rowset.updateNull(columnName);
670     }
671
672     /**
673      * The listener will be notified whenever an event occurs on this RowSet object.
674      *
675      * Note: if the RowSetListener object is null, this method silently discards the null
676      * value and does not add a null reference to the set of listeners.
677      *
678      * Note: if the listener is already set, and the new RowSetListerner instance is added
679      * to the set of listeners already registered to receive event notifications from this
680      * RowSet
681      *
682      * @param listener - an object that has implemented the javax.sql.RowSetListener interface
683      * and wants to be notified of any events that occur on this RowSet object; May be null
684      */

685     public void addRowSetListener(RowSetListener JavaDoc listener){
686         rowset.addRowSetListener(listener);
687     }
688
689     /**
690      * Removes the designated object from this RowSet object's list of listeners. If the given
691      * argument is not a registered listener, this method does nothing.
692      * Note: if the RowSetListener object is null, this method silently discards the null value
693      * @param listener - a RowSetListener object that is on the list of listeners for this RowSet object
694      */

695     public void removeRowSetListener(RowSetListener JavaDoc listener){
696         rowset.removeRowSetListener(listener);
697     }
698
699     /**
700      * Maps the given column name to its column index
701      * @param columnIndex - column number first column is 1, second column is 2 .....
702      * @return the column name of the given column index
703      * @throws SQLException - if the object does not contain columnIndex or a access
704      * error occurs
705      */

706     public String JavaDoc getColumnName(int columnIndex) throws SQLException JavaDoc{
707         return metaData.getColumnName(columnIndex);
708     }
709
710     /**
711      * Get the designated column's index
712      * @param columnName - name of the column
713      * @return returns the corresponding column index.
714      * @throws SQLException - if a data access error
715      */

716     public int getColumnIndex(String JavaDoc columnName) throws SQLException JavaDoc{
717         return rowset.findColumn(columnName);
718     }
719
720     /**
721      * Retrieves the designated column's type
722      * @param columnName - name of the column
723      * @return SQL type from java.sql.Types
724      * @throws SQLException - if a data access error occurs
725      */

726     public int getColumnType(String JavaDoc columnName) throws SQLException JavaDoc{
727         return metaData.getColumnType(getColumnIndex(columnName));
728     }
729
730     /**
731      * Retrieves the designated column's type
732      * @param columnIndex - column number first column is 1, second column is 2 .....
733      * @return SQL type from java.sql.Types
734      * @throws SQLException - if a data access error occurs
735      */

736     public int getColumnType(int columnIndex) throws SQLException JavaDoc{
737         return metaData.getColumnType(columnIndex);
738     }
739
740     /**
741      * Retrieves the current row number. The first row is number 1, the second number 2,
742      * and so on.
743      * @return the current row number; 0 if there is no current row
744      * @throws SQLException - if a data access error occurs
745      */

746     public int getRow() throws SQLException JavaDoc{
747         return rowset.getRow();
748     }
749
750     /**
751      * Returns the number of columns in this ResultSet object
752      * @return the number of columns
753      * @throws SQLException - if a data access error occurs
754      */

755     public int getColumnCount() throws SQLException JavaDoc{
756         return metaData.getColumnCount();
757     }
758
759     /**
760      * Moves the cursor down one row from its current position. A ResultSet cursor is
761      * initially positioned before the first row; the first call to the method next makes the
762      * first row the current row; the second call makes the second row the current row,
763      * and so on.
764      * If an input stream is open for the current row, a call to the method next will
765      * implicitly close it. A ResultSet object's warning chain is cleared when a new row
766      * is read.
767      * @return true if the new current row is valid; false if there are no more rows
768      * @throws SQLException - if a data access error occurs
769      */

770     public boolean next() throws SQLException JavaDoc{
771         return rowset.next();
772     }
773
774     /**
775      * Moves the cursor to the previous row in this ResultSet object.
776      * @return true if the cursor is on a valid row; false if it is off the result set
777      * @throws SQLException - if a data access error occurs
778      */

779     public boolean previous() throws SQLException JavaDoc{
780         return rowset.previous();
781     }
782
783     /**
784      * Moves the cursor to the last row in this ResultSet object.
785      * @return true if the cursor is on a valid row; false if there are no rows in the
786      * result set
787      * @throws SQLException - if a data access error occurs
788      */

789     public boolean last() throws SQLException JavaDoc{
790         return rowset.last();
791     }
792
793     /**
794      * Moves the cursor to the first row in this ResultSet object.
795      * @return true if the cursor is on a valid row; false if there are no rows in the
796      * result set
797      * @throws SQLException - if a data access error occurs
798      */

799     public boolean first() throws SQLException JavaDoc{
800         return rowset.first();
801     }
802
803     /**
804      * Retrieves whether the cursor is on the first row of this ResultSet object.
805      * @return true if the cursor is on the first row; false otherwise
806      * @throws SQLException - if a data access error occurs
807      */

808     public boolean isFirst() throws SQLException JavaDoc{
809         return rowset.isFirst();
810     }
811
812     /**
813      * Retrieves whether the cursor is on the last row of this ResultSet object.
814      * Note: Calling the method isLast may be expensive because the JDBC driver might
815      * need to fetch ahead one row in order to determine whether the current row is the
816      * last row in the result set.
817      * @return true if the cursor is on the last row; false otherwise
818      * @throws SQLException - if a data access error occurs
819      */

820     public boolean isLast() throws SQLException JavaDoc{
821         return rowset.isLast();
822     }
823
824     /**
825      * Moves the cursor to the front of this ResultSet object, just before the first row.
826      * This method has no effect if the result set contains no rows.
827      * @throws SQLException - if a data access error occurs
828      */

829     public void beforeFirst() throws SQLException JavaDoc{
830         rowset.beforeFirst();
831     }
832
833     /**
834      *<pre>
835      * Moves the cursor to the given row number in this ResultSet object.
836      * If the row number is positive, the cursor moves to the given row number with
837      * respect to the beginning of the result set. The first row is row 1, the second is
838      * row 2, and so on.
839      * If the given row number is negative, the cursor moves to an absolute row position
840      * with respect to the end of the result set. For example, calling the method absolute(-1)
841      * positions the cursor on the last row; calling the method absolute(-2) moves the cursor
842      * to the next-to-last row, and so on.
843      * An attempt to position the cursor beyond the first/last row in the result set leaves
844      * the cursor before the first row or after the last row.
845      *</pre>
846      * @param row - the number of the row to which the cursor should move.
847      * @return true if the cursor is on the result set; false otherwise
848      * @throws SQLException - if a database access error occurs
849      */

850     public boolean absolute(int row) throws SQLException JavaDoc{
851         return rowset.absolute(row);
852     }
853
854     /**
855      * Updates the underlying database with the new contents of the current row of this
856      * ResultSet object. This method cannot be called when the cursor is on the insert row.
857      * @throws SQLException - if a data access error occurs or if this method is called when
858      * the cursor is on the insert row
859      */

860     public void updateRow() throws SQLException JavaDoc{
861         rowset.updateRow();
862     }
863
864     /**
865      * Moves the cursor to the remembered cursor position, usually the current row.
866      * This method has no effect if the cursor is not on the insert row.
867      * @throws SQLException - if a data access error occurs
868      */

869     public void moveToCurrentRow() throws SQLException JavaDoc{
870         rowset.moveToCurrentRow();
871     }
872
873     /**
874      * Moves the cursor to the insert row. The current cursor position is remembered
875      * while the cursor is positioned on the insert row. The insert row is a special
876      * row associated with an updatable result set. It is essentially a buffer where
877      * a new row may be constructed by calling the updater methods prior to inserting
878      * the row into the result set. Only the updater, getter, and insertRow methods may
879      * be called when the cursor is on the insert row. All of the columns in a result
880      * set must be given a value each time this method is called before calling insertRow.
881      * An updater method must be called before a getter method can be called on a column
882      * value.
883      * @throws SQLException - if a data access error occurs
884      */

885     public void moveToInsertRow() throws SQLException JavaDoc{
886         rowset.moveToInsertRow();
887     }
888
889     /**
890      * Inserts the contents of the insert row into this ResultSet object and into the
891      * database. The cursor must be on the insert row when this method is called.
892      * @throws SQLException - if a data access error occurs,if this method is called when
893      * the cursor is not on the insert row, or if not all of non-nullable columns in the
894      * insert row have been given a value
895      */

896     public void insertRow() throws SQLException JavaDoc{
897         rowset.insertRow();
898     }
899
900     /**
901      * Deletes the current row from this ResultSet object and from the underlying
902      * database. This method cannot be called when the cursor is on the insert row.
903      * @throws SQLException - if a data access error occurs or if this method is called
904      * when the cursor is on the insert row
905      */

906     public void deleteRow() throws SQLException JavaDoc{
907         rowset.deleteRow();
908     }
909
910     /**
911      * Cancels the updates made to the current row in this ResultSet object. This method
912      * may be called after calling an updater method(s) and before calling the method
913      * updateRow to roll back the updates made to a row. If no updates have been made or
914      * updateRow has already been called, this method has no effect
915      * @throws SQLException - if a data access error occurs or if this method is called when
916      * the cursor is on the insert row
917      */

918     public void cancelRowUpdates() throws SQLException JavaDoc{
919         rowset.cancelRowUpdates();
920     }
921
922     /**
923      * Refreshes the current row with its most recent value in the database. This
924      * method cannot be called when the cursor is on the insert row.
925      * The refreshRow method provides a way for an application to explicitly tell the
926      * JDBC driver to refetch a row(s) from the database. An application may want to
927      * call refreshRow when caching or prefetching is being done by the JDBC driver to
928      * fetch the latest value of a row from the database. The JDBC driver may actually
929      * refresh multiple rows at once if the fetch size is greater than one.
930      * All values are refetched subject to the transaction isolation level and cursor
931      * sensitivity. If refreshRow is called after calling an updater method, but before
932      * calling the method updateRow, then the updates made to the row are lost. Calling
933      * the method refreshRow frequently will likely slow performance
934      * @throws SQLException - if a data access error occurs or if this method is called
935      * when the cursor is on the insert row
936      */

937     public void refreshRow() throws SQLException JavaDoc{
938         rowset.refreshRow();
939     }
940
941 }
942  /*
943   * $Log: SSJdbcRowSetImpl.java,v $
944   * Revision 1.13 2005/02/12 03:27:09 yoda2
945   * Added bound properties (for beans).
946   *
947   * Revision 1.12 2005/02/11 22:59:56 yoda2
948   * Imported PropertyVetoException and added some bound properties.
949   *
950   * Revision 1.11 2005/02/11 20:16:31 yoda2
951   * Added infrastructure to support property & vetoable change listeners (for beans).
952   *
953   * Revision 1.10 2005/02/10 15:53:09 yoda2
954   * Added class descriptions to JavaDoc.
955   *
956   * Revision 1.9 2005/02/09 23:04:01 yoda2
957   * JavaDoc cleanup.
958   *
959   * Revision 1.8 2005/02/09 06:39:44 prasanth
960   * Added PropertyChangeSupport
961   *
962   * Revision 1.7 2005/02/04 22:49:09 yoda2
963   * API cleanup & updated Copyright info.
964   *
965   * Revision 1.6 2005/01/18 20:58:11 prasanth
966   * Added function to get & set bytes.
967   *
968   * Revision 1.5 2004/11/11 14:45:57 yoda2
969   * Using TextPad, converted all tabs to "soft" tabs comprised of four actual spaces.
970   *
971   * Revision 1.4 2004/11/01 15:53:19 yoda2
972   * Fixed various JavaDoc errors.
973   *
974   * Revision 1.3 2004/10/29 20:45:30 yoda2
975   * Fixed issue with setCommand() not updating underlying JdbcRowSetImpl.
976   *
977   * Revision 1.2 2004/10/28 15:27:17 prasanth
978   * Calling setType & setConcurrency after instanciating JdbcRowSetImpl
979   *
980   * Revision 1.1 2004/10/25 21:47:50 prasanth
981   * Initial Commit
982   *
983   */
Popular Tags