KickJava   Java API By Example, From Geeks To Geeks.

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


1 package in.co.daffodil.db.jdbc;
2
3 import com.daffodilwoods.database.resource.*;
4 import java.sql.Date JavaDoc;
5 import java.sql.*;
6 import java.util.*;
7 import java.io.*;
8 import java.io.*;
9 import java.math.BigDecimal JavaDoc;
10
11 public class DaffodilDBRowSet //extends DaffodilDBResultSet implements RowSet,RowSetInternal
12
{
13 /* ArrayList rowListeners;
14    DaffodilDBRowSetProperties rowSetProperties;
15    RowSetMetaData rowSetMetaData;
16    public DaffodilDBRowSet() {
17       rowSetProperties = new DaffodilDBRowSetProperties();
18       rowListeners = new ArrayList(5);
19    }
20
21    /**
22      * Registers the given listener so that it will be notified of events that
23      * occur on this RowSet object.
24
25      * @Param:
26          listener - a component that has implemented the RowSetListener interface
27             and wants to be notified when events occur on this RowSet object
28
29      **
30    public void addRowSetListener(RowSetListener rowSetListener){
31       rowListeners.add(rowSetListener);
32    }
33
34    /**
35      * Fills this RowSet object with data.
36      * The execute method may use the following properties to create a
37      * connection for reading data: url, data source name, user name,
38      * password, transaction isolation, and type map. The execute method
39      * may use the following properties to create a statement to execute a
40      * command: command, read only, maximum field size, maximum rows,
41      * escape processing, and query timeout.
42
43      * If the required properties have not been set, an
44      * exception is thrown. If this method is successful,
45      * the current contents of the rowset are discarded and
46      * the rowset's metadata is also (re)set. If there are outstanding
47      * updates, they are ignored.
48
49      * If this RowSet object does not maintain a continuous connection with
50      * its source of data, it may use a reader (a RowSetReader object) to
51      * fill itself with data. In this case, a reader will have been
52      * registered with this RowSet object, and the method execute will
53      * call on the reader's readData method as part of its implementation.
54
55      Throws:
56         SQLException - if a database access error occurs or any of the
57           properties necessary for making a connection and creating a
58            statement have not been set
59
60      **
61
62    public void execute() throws SQLException{
63       fireRowSetChangeListeners();
64    }
65
66    /**
67      * Clears the parameters set for this RowSet object's command.
68      * In general, parameter values remain in force for repeated use
69      * of a RowSet object. Setting a parameter value automatically clears
70      * its previous value. However, in some cases it is useful to immediately
71      * release the resources used by the current parameter values,
72      * which can be done by calling the method clearParameters.
73      *
74    public void clearParameters() throws SQLException{
75       rowSetProperties.clearAll();
76    }
77
78    /**
79      * Sets the data source name property for this RowSet object to the
80      * given String.
81      * The value of the data source name property can be used to do a
82      * lookup of a DataSource object that has been registered with a naming
83      * service. After being retrieved, the DataSource object can be used to
84      * create a connection to the data source that it represents.
85
86      * @params:
87            name - the logical name of the data source for this RowSet object
88
89      **
90    public void setDataSourceName(String name) throws SQLException{
91       rowSetProperties.dataSourceName = name;
92    }
93
94    /**
95      * Retrieves the logical name that identifies the data source for
96      * this RowSet object. Users should set either the url property or
97      * the data source name property.
98      * The rowset will use the property that was set more recently to get
99      * a connection.
100
101      * @returns: a data source name
102      **
103    public String getDataSourceName() {
104       return rowSetProperties.dataSourceName;
105    }
106
107
108    /**
109      * Sets escape processing for this RowSet object on or off.
110      * If escape scanning is on (the default), the driver will do escape
111      * substitution before sending an SQL statement to the database.
112
113      * @params:
114           enable - true to enable escape processing; false to disable it
115
116      **
117    public void setEscapeProcessing(boolean enable) throws SQLException{
118       rowSetProperties.escapeProcessing = enable;
119    }
120
121    /**
122      * Retrieves whether escape processing is enabled for this RowSet object.
123      * If escape scanning is enabled, which is the default,
124      * the driver will do escape substitution before sending an SQL statement
125      * to the database.
126
127      * @returns: true if escape processing is enabled; false if it is disabled
128      **
129    public boolean getEscapeProcessing() throws SQLException{
130       return rowSetProperties.escapeProcessing;
131    }
132
133    /**
134      * Retrieves the username used to create a database connection for
135      * this RowSet object. The username property is set at run time before
136      * calling the method execute. It is not usually part of the serialized state
137      * of a RowSet object.
138
139      * @returns: the username property
140      **
141    public String getUsername() {
142       return rowSetProperties.userName;
143    }
144
145    /**
146      * Sets the username property for this RowSet object to the given String.
147
148      * @params:
149            name - a user name
150      **
151    public void setUsername(String userName) {
152       rowSetProperties.userName = userName;
153    }
154
155   /**
156     * Sets the URL this RowSet object will use when it uses the DriverManager to
157     * create a connection. Setting this property is optional. If a URL is used,
158     * a JDBC driver that accepts the URL must be loaded by the application
159     * before the rowset is used to connect to a database. The rowset will use
160     * the URL internally to create a database connection when reading or
161     * writing data. Either a URL or a data source name is used to create a
162     * connection, whichever was specified most recently.
163
164     * params:
165        url - a string value; may be null
166     **
167   public void setUrl(String url){
168       rowSetProperties.url = url;
169    }
170
171    /**
172      * Retrieves the url property this RowSet object will use to create a
173      * connection if it uses the DriverManager instead of a DataSource object
174      * to establish the connection. The default value is null.
175
176      * @eturns: a string url
177      **
178    public String getUrl() throws SQLException{
179       return rowSetProperties.url;
180    }
181
182    /**
183      * Sets the database password for this RowSet object to the given String.
184
185      * @params:
186           password - the password string
187      **
188    public void setPassword(String password) {
189       rowSetProperties.password = password;
190    }
191
192    /**
193      * Retrieves the password used to create a database connection.
194      * The password property is set at run time before calling the method execute.
195      * It is not usually part of the serialized state of a RowSet object.
196
197      * @returns: the password for making a database connection
198      **
199    public String getPassword() {
200       return rowSetProperties.password;
201    }
202
203    /**
204      * Sets the maximum time the driver will wait for a statement to
205      * execute to the given number of seconds. If this limit is exceeded,
206      * an SQLException is thrown.
207
208      * @params:
209             seconds - the new query timeout limit in seconds;
210                 zero means that there is no limit
211      **
212    public void setQueryTimeout(int seconds) {
213       rowSetProperties.queryTimeout = seconds;
214    }
215
216    /**
217      * Retrieves the maximum number of seconds the driver will wait for a
218      * statement to execute. If this limit is exceeded, an SQLException
219      * is thrown.
220
221      * @returns: the current query timeout limit in seconds;
222                 zero means unlimited
223      **
224    public int getQueryTimeout() throws SQLException{
225       return rowSetProperties.queryTimeout;
226    }
227
228    /**
229      * Sets whether this RowSet object is read-only to the given boolean.
230
231      * @params:
232           value - true if read-only; false if updatable
233      **
234    public void setReadOnly(boolean isReadOnly) {
235       rowSetProperties.isReadOnly = isReadOnly;
236    }
237
238    /**
239      * Retrieves whether this RowSet object is read-only.
240      * If updates are possible, the default is for a rowset to be updatable.
241      * Attempts to update a read-only rowset will result in an SQLException being thrown.
242
243      * @returns: true if this RowSet object is read-only;
244                     false if it is updatable
245      **
246    public boolean isReadOnly() {
247       return rowSetProperties.isReadOnly;
248    }
249
250    /**
251      * Removes the specified listener from the list of components that will
252      * be notified when an event occurs on this RowSet object.
253
254      * @param:
255              listener - a component that has been registered as a listener
256                   for this RowSet object
257      **
258    public void removeRowSetListener(RowSetListener listener){
259       int index = rowListeners.lastIndexOf(listener);
260       if(index != -1)
261          rowListeners.remove(listener);
262    }
263
264    /**
265      * Sets the maximum number of rows that this RowSet object can contain
266      * to the specified number. If the limit is exceeded, the excess rows
267      * are silently dropped.
268
269      * @params:
270           max - the new maximum number of rows; zero means unlimited
271      **
272    public void setMaxRows(int max){
273       rowSetProperties.maxRows = max;
274    }
275
276    /**
277      * Retrieves the maximum number of rows that this RowSet object can contain.
278      * If the limit is exceeded, the excess rows are silently dropped.
279
280      * @returns: the current maximum number of rows that this RowSet object can
281               contain; zero means unlimited
282
283      **
284    public int getMaxRows() throws SQLException{
285       return rowSetProperties.maxRows;
286    }
287
288    /**
289      * Sets the maximum number of bytes that can be returned for a column
290      * value to the given number of bytes. This limit applies only to
291      * BINARY, VARBINARY, LONGVARBINARYBINARY, CHAR, VARCHAR, and
292      * LONGVARCHAR columns. If the limit is exceeded, the excess data is
293      * silently discarded. For maximum portability, use values greater than 256.
294
295      * @params:
296             max - the new max column size limit in bytes; zero means unlimited
297      **
298    public void setMaxFieldSize(int max){
299       rowSetProperties.maxFieldSize = max;
300    }
301
302    /**
303      * Retrieves the maximum number of bytes that may be returned for
304      * certain column values. This limit applies only to BINARY, VARBINARY,
305      * LONGVARBINARYBINARY, CHAR, VARCHAR, and LONGVARCHAR columns.
306      * If the limit is exceeded, the excess data is silently discarded.
307
308      * @returns: the current maximum column size limit;
309                      zero means that there is no limit
310      **
311
312    public int getMaxFieldSize() throws SQLException{
313       return rowSetProperties.maxFieldSize;
314    }
315
316    /**
317      * Sets the transaction isolation level for this RowSet obejct.
318
319      * @params:
320          level - the transaction isolation level; one of
321           Connection.TRANSACTION_READ_UNCOMMITTED,
322            Connection.TRANSACTION_READ_COMMITTED,
323              Connection.TRANSACTION_REPEATABLE_READ,
324                or Connection.TRANSACTION_SERIALIZABLE
325      **
326    public void setTransactionIsolation(int level) {
327       rowSetProperties.transactionIsolation = level;
328    }
329
330    /**
331      * Retrieves the transaction isolation level set for this RowSet object.
332
333      * @returns: the transaction isolation level;
334          one of Connection.TRANSACTION_READ_UNCOMMITTED,
335            Connection.TRANSACTION_READ_COMMITTED,
336             Connection.TRANSACTION_REPEATABLE_READ, or
337               Connection.TRANSACTION_SERIALIZABLE
338      **
339
340    public int getTransactionIsolation() {
341       return rowSetProperties.transactionIsolation;
342    }
343
344    /**
345      * Installs the given java.util.Map object as the default type map for
346      * this RowSet object. This type map will be used unless another type
347      * map is supplied as a method parameter.
348
349      * @params:
350            map - a java.util.Map object containing the names of
351              SQL user-defined types and the Java classes to which
352                they are to be mapped
353      **
354    public void setTypeMap(Map typeMap) {
355       rowSetProperties.typeMap = typeMap;
356    }
357
358    /**
359      * Retrieves the Map object associated with this RowSet object,
360      * which specifies the custom mapping of SQL user-defined types, if any.
361      * The default is for the type map to be empty.
362
363      * @returns: a java.util.Map object containing the names of SQL user-defined
364          types and the Java classes to which they are to be mapped
365      **
366    public Map getTypeMap() throws SQLException{
367       return rowSetProperties.typeMap;
368    }
369
370    /**
371      * Sets the type of this RowSet object to the given type.
372      * This method is used to change the type of a rowset, which is by
373      * default read-only and non-scrollable.
374
375      * @params:
376            type - one of the ResultSet constants specifying a type:
377              ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE,
378                or ResultSet.TYPE_SCROLL_SENSITIVE
379      **
380    public void setType(int type) {
381       rowSetProperties.type = type;
382    }
383
384    /**
385      * Sets this RowSet object's command property to the given SQL query.
386      * This property is optional when a rowset gets its data from a data
387      * source that does not support commands, such as a spreadsheet.
388
389      * @params:
390             cmd - the SQL query that will be used to get the data for this
391                    RowSet object; may be null
392      **
393    public void setCommand(String cmd) {
394       rowSetProperties.cmd = cmd;
395    }
396
397    /**
398      * Retrieves this RowSet object's command property.
399      * The command property contains a command string, which must be
400      * an SQL query, that can be executed to fill the rowset with data.
401      * The default value is null.
402
403      * @returns: the command string; may be null
404      **
405    public String getCommand() {
406       return rowSetProperties.cmd;
407    }
408
409    /**
410      * Sets the concurrency of this RowSet object to the given concurrency level. This method is used to change the concurrency level
411      * of a rowset, which is by default ResultSet.CONCUR_READ_ONLY
412
413      * @params:
414            concurrency - one of the ResultSet constants specifying a
415             concurrency level: ResultSet.CONCUR_READ_ONLY or
416               ResultSet.CONCUR_UPDATABLE
417      **
418    public void setConcurrency(int concurrency) throws SQLException{
419        rowSetProperties.concurrency = concurrency;
420    }
421
422    /**
423      * Sets the designated parameter in this RowSet object's command with the
424      * given Array value. The driver will convert this to the ARRAY value
425      * that the Array object represents before sending it to the database.
426
427      * @params:
428           parameterIndex - the first parameter is 1, the second is 2, ...
429           x - an object representing an SQL array
430      **
431    public void setArray(int parameterIndex,Array x) throws SQLException{
432      rowSetProperties.setParameter(parameterIndex -1,x);
433    }
434
435    /**
436      * Sets the designated parameter in this RowSet object's command to the given
437      * java.io.InputStream value. It may be more practical to send a very large
438      * ASCII value via a java.io.InputStream rather than as a LONGVARCHAR
439      * parameter. The driver will read the data from the stream as needed until
440      * it reaches end-of-file.
441
442      Note: This stream object can either be a standard Java stream object or
443         your own subclass that implements the standard interface.
444
445      * @params:
446          parameterIndex - the first parameter is 1, the second is 2, ...
447          x - the Java input stream that contains the ASCII parameter value
448          length - the number of bytes in the stream
449      **
450
451    public void setAsciiStream(int parameterIndex,InputStream x,int length)
452     throws SQLException{
453       byte[] bytes = new byte[length];
454       try{
455         x.read(bytes);
456       }catch(Exception ex){
457         throw new SQLException(ResourceManager.dserrors.getString("DSE146"));
458       }
459       rowSetProperties.setParameter(parameterIndex -1,bytes);
460    }
461
462    /**
463      * Sets the designated parameter in this RowSet object's command to the
464      * given java.math.BigDeciaml value. The driver converts this to an SQL
465      * NUMERIC value before sending it to the database.
466
467      * @parameters:
468          parameterIndex - the first parameter is 1, the second is 2, ...
469                       x - the parameter value
470      **
471    public void setBigDecimal(int parameterIndex,BigDecimal x)throws SQLException
472    {
473      rowSetProperties.setParameter(parameterIndex -1,x);
474    }
475
476
477    /**
478      * Sets the designated parameter in this RowSet object's command to the given
479      * java.io.InputStream value. It may be more practical to send a very large
480      * binary value via a java.io.InputStream rather than as a LONGVARBINARY
481      * parameter. The driver will read the data from the stream as needed until
482      * it reaches end-of-file.
483
484      Note: This stream object can either be a standard Java stream object
485         or your own subclass that implements the standard interface.
486
487      * @params:
488           parameterIndex - the first parameter is 1, the second is 2, ...
489           x - the java input stream which contains the binary parameter value
490           length - the number of bytes in the stream
491      **
492
493    public void setBinaryStream(int parameterIndex,InputStream x,int length)
494        throws SQLException{
495      byte[] bytes = new byte[length];
496      try{
497         x.read(bytes);
498      }catch(Exception ex){
499         throw new SQLException(ResourceManager.dserrors.getString("DSE146"));
500       }
501      rowSetProperties.setParameter(parameterIndex - 1,bytes);
502    }
503
504    /**
505      * Sets the designated parameter in this RowSet object's command with
506      * the given Blob value. The driver will convert this to the BLOB value
507      * that the Blob object represents before sending it to the database.
508
509      * @params:
510            columnIndex - the first parameter is 1, the second is 2, ...
511            x - an object representing a BLOB
512      **
513
514    public void setBlob(int parameterIndex,Blob x)throws SQLException{
515       byte[] bytes = x.getBytes(1,(int)x.length());
516       rowSetProperties.setParameter(parameterIndex -1,bytes);
517    }
518
519    /**
520      * Sets the designated parameter in this RowSet object's command to
521      * the given Java boolean value. The driver converts this to an SQL BIT
522      * value before sending it to the database.
523
524      * @params:
525          parameterIndex - the first parameter is 1, the second is 2, ...
526                       x - the parameter value
527      **
528
529    public void setBoolean(int parameterIndex,boolean x)throws SQLException{
530      rowSetProperties.setParameter(parameterIndex -1 ,new Boolean(x));
531    }
532
533    /**
534      * Sets the designated parameter in this RowSet object's command to the
535      * given Java byte value. The driver converts this to an SQL TINYINT
536      * value before sending it to the database.
537
538      * @params:
539           parameterIndex - the first parameter is 1, the second is 2, ...
540                        x - the parameter value
541      **
542    public void setByte(int parameterIndex,byte x) throws SQLException{
543       rowSetProperties.setParameter(parameterIndex -1 ,new Byte(x));
544    }
545
546    /**
547      * Sets the designated parameter in this RowSet object's command to the
548      * given Java array of byte values. Before sending it to the database,
549      * the driver converts this to an SQL VARBINARY or LONGVARBINARY value,
550      * depending on the argument's size relative to the driver's limits on
551      * VARBINARY values.
552
553      * @params:
554           parameterIndex - the first parameter is 1, the second is 2, ...
555                        x - the parameter value
556
557      **
558    public void setBytes(int parameterIndex,byte[] x) throws SQLException{
559      rowSetProperties.setParameter(parameterIndex -1 ,x);
560    }
561
562    /**
563      * Sets the designated parameter in this RowSet object's command to the
564      * given java.io.Reader value. It may be more practical to send a very
565      * large UNICODE value via a java.io.Reader rather than as a LONGVARCHAR
566      * parameter. The driver will read the data from the stream as needed
567      * until it reaches end-of-file.
568
569         Note: This stream object can either be a standard Java stream
570         object or your own subclass that implements the standard interface.
571
572      * @params:
573          parameterIndex - the first parameter is 1, the second is 2, ...
574                  reader - the Reader object that contains the UNICODE data to be set
575                  length - the number of characters in the stream
576      **
577    public void setCharacterStream(int parameterIndex,Reader reader,int length)
578               throws SQLException{
579      char[] chars = new char[length];
580      try{
581         reader.read(chars);
582      }catch(Exception ex){
583         throw new SQLException(ResourceManager.dserrors.getString("DSE146"));
584       }
585       rowSetProperties.setParameter(parameterIndex -1,new String(chars));
586    }
587
588    /**
589      * Sets the designated parameter in this RowSet object's command with
590      * the given Clob value. The driver will convert this to the CLOB value
591      * that the Clob object represents before sending it to the database.
592
593      * params:
594         columnIndex - the first parameter is 1, the second is 2, ...
595         x - an object representing a CLOB
596      **
597    public void setClob(int parameterIndex,Clob x)throws SQLException {
598      String value = x.getSubString(1,(int)x.length());
599      rowSetProperties.setParameter(parameterIndex -1,value);
600    }
601
602    /**
603      * Sets the designated parameter in this RowSet object's command to
604      * the given Java int value. The driver converts this to an
605      * SQL INTEGER value before sending it to the database.
606
607      * @params:
608            parameterIndex - the first parameter is 1, the second is 2, ...
609                    value - the parameter value
610      **
611    public void setInt(int parameterIndex, int value) throws SQLException {
612       rowSetProperties.setParameter(parameterIndex-1 ,new Integer(value));
613    }
614
615    /**
616      * Sets the designated parameter in this RowSet object's command to
617      * the given Java float value. The driver converts this to an
618      * SQL REAL value before sending it to the database.
619
620      * @params:
621          parameterIndex - the first parameter is 1, the second is 2, ...
622                   value - the parameter value
623
624      **
625    public void setFloat(int parameterIndex, float value) throws SQLException {
626       rowSetProperties.setParameter(parameterIndex-1 ,new Float(value));
627    }
628
629    /**
630      * Sets the designated parameter in this RowSet object's command to
631      * the given Java long value. The driver converts this to an
632      * SQL BIGINT value before sending it to the database.
633
634      * @params:
635        parameterIndex - the first parameter is 1, the second is 2, ...
636                 value - the parameter value
637      **
638    public void setLong(int parameterIndex,long value)throws SQLException {
639       rowSetProperties.setParameter(parameterIndex-1 ,new Long(value));
640    }
641
642    /**
643      * Sets the designated parameter in this RowSet object's command to
644      * the given Java double value. The driver converts this to an
645      * SQL DOUBLE value before sending it to the database.
646
647      * @params:
648          parameterIndex - the first parameter is 1, the second is 2, ...
649                   value - the parameter value
650
651      **
652    public void setDouble(int parameterIndex, double value) throws SQLException {
653       rowSetProperties.setParameter(parameterIndex -1,new Double(value));
654    }
655
656    /**
657      * Sets the designated parameter in this RowSet object's command to
658      * the given java.sql.Date value. The driver converts this to an
659      * SQL DATE value before sending it to the database, using the
660      * default java.util.Calendar to calculate the date.
661
662      * @params:
663         parameterIndex - the first parameter is 1, the second is 2, ...
664                  value - the parameter value
665
666      **
667    public void setDate(int parameterIndex, Date value) throws SQLException {
668       rowSetProperties.setParameter(parameterIndex -1 ,value);
669    }
670
671    /**
672      * Sets the designated parameter in this RowSet object's command with
673      * the given java.sql.Date value. The driver will convert this to an
674      * SQL DATE value, using the given java.util.Calendar object to calculate
675      * the date.
676
677      * @params:
678           parameterIndex - the first parameter is 1, the second is 2, ...
679           x - the parameter value
680           cal - the java.util.Calendar object to use for calculating the
681                           date
682
683      **
684    public void setDate(int parameterIndex,Date x,Calendar cal) throws SQLException
685    {
686       cal.setTime(x);
687       Date date = new com.daffodilwoods.daffodildb.utils.DBDate(cal.get(Calendar.YEAR),cal.get(Calendar.MONTH),cal.get(Calendar.DATE));
688       rowSetProperties.setParameter(parameterIndex -1,date);
689    }
690
691    /**
692      * Sets the designated parameter in this RowSet object's command with the
693      * given java.sql.Timestamp value. The driver will convert this to an
694      * SQL TIMESTAMP value, using the given java.util.Calendar object to
695      * calculate it, before sending it to the database.
696
697      * @params:
698          parameterIndex - the first parameter is 1, the second is 2, ...
699          x - the parameter value
700          cal - the java.util.Calendar object to use for calculating the timestamp
701      **
702    public void setTimestamp(int parameterIndex,Timestamp x,Calendar cal)throws SQLException
703    {
704      cal.setTime(x);
705      Timestamp calTimeStamp = new Timestamp( cal.getTime().getTime() );
706      rowSetProperties.setParameter(parameterIndex -1,calTimeStamp);
707    }
708
709    /**
710      * Sets the designated parameter in this RowSet object's command to
711      * the given java.sql.Timestamp value. The driver converts this to
712      * an SQL TIMESTAMP value before sending it to the database,
713      * using the default java.util.Calendar to calculate it.
714
715      * @params:
716          parameterIndex - the first parameter is 1, the second is 2, ...
717                   value - the parameter value
718      **
719    public void setTimestamp(int parameterIndex,Timestamp value) throws SQLException
720    {
721       rowSetProperties.setParameter(parameterIndex -1,value);
722    }
723
724    /**
725      * Sets the designated parameter in this RowSet object's command with
726      * the given java.sql.Time value. The driver will convert this to an
727      * SQL TIME value, using the given java.util.Calendar object to
728      * calculate it, before sending it to the database.
729
730      * @params:
731          parameterIndex - the first parameter is 1, the second is 2, ...
732                x - the parameter value
733          cal - the java.util.Calendar object to use for calculating the time
734      **
735    public void setTime(int parameterIndex,Time x,Calendar cal)throws SQLException
736    {
737       cal.setTime(x);
738       Time calTime = new Time(cal.get(Calendar.HOUR),cal.get(Calendar.MINUTE),
739                              cal.get(Calendar.SECOND) );
740       rowSetProperties.setParameter(parameterIndex -1,calTime);
741    }
742
743    /**
744      * Sets the designated parameter in this RowSet object's command to
745      * the given java.sql.Time value. The driver converts this to an
746      * SQL TIME value before sending it to the database, using the
747      * default java.util.Calendar to calculate it.
748
749      * @params:
750         parameterIndex - the first parameter is 1, the second is 2, ...
751              value - the parameter value
752      **
753    public void setTime(int parameterIndex,Time value) throws SQLException {
754      rowSetProperties.setParameter(parameterIndex -1,value);
755    }
756
757    /**
758      * Sets the designated parameter in this RowSet object's command to
759      * the given Java String value. Before sending it to the database,
760      * the driver converts this to an SQL VARCHAR or LONGVARCHAR value,
761      * depending on the argument's size relative to the driver's limits
762      * on VARCHAR values.
763
764      * @Params:
765        parameterIndex - the first parameter is 1, the second is 2, ...
766          value - the parameter value
767      **
768    public void setString(int parameterIndex,String value)throws SQLException {
769       rowSetProperties.setParameter (parameterIndex -1,value);
770    }
771
772    /**
773      * Sets the designated parameter in this RowSet object's command to
774      * the given Java short value. The driver converts this to an
775      * SQL SMALLINT value before sending it to the database.
776
777      * @params:
778        parameterIndex - the first parameter is 1, the second is 2, ...
779           value - the parameter value
780      **
781   public void setShort(int parameterIndex, short value) throws SQLException{
782       rowSetProperties.setParameter(parameterIndex -1,new Short(value));
783   }
784
785   /**
786     * Sets the designated parameter in this RowSet object's command with
787     * the given Ref value. The driver will convert this to the appropriate
788     * REF(<structured-type>) value.
789
790     * @params:
791           parameterIndex - the first parameter is 1, the second is 2, ...
792           value - an object representing data of an SQL REF type
793     **
794   public void setRef(int parameterIndex,Ref value) throws SQLException{
795       ;
796   }
797
798    /**
799      * Sets the designated parameter in this RowSet object's SQL command
800      * to SQL NULL.
801
802       Note: You must specify the parameter's SQL type.
803
804      * @params:
805         parameterIndex - the first parameter is 1, the second is 2, ...
806          sqlType - a SQL type code defined by java.sql.Types
807         Throws:
808           SQLException - if a database access error occurs
809      **
810    public void setNull(int parameterIndex,int sqlType) throws SQLException{
811       rowSetProperties.setParameter(parameterIndex -1 , null);
812    }
813
814    /**
815      * Sets the designated parameter in this RowSet object's SQL command to
816      * SQL NULL. This version of the method setNull should be used for
817      * SQL user-defined types (UDTs) and REF type parameters.
818      * Examples of UDTs include: STRUCT, DISTINCT, JAVA_OBJECT,
819      * and named array types.
820
821       Note: To be portable, applications must give the SQL type code and
822         the fully qualified SQL type name when specifying a NULL UDT or REF
823         parameter. In the case of a UDT, the name is the type name of
824         the parameter itself. For a REF parameter, the name is the type name
825         of the referenced type. If a JDBC driver does not need the type code
826         or type name information, it may ignore it. Although it is intended
827         for UDT and REF parameters, this method may be used to set a null
828         parameter of any JDBC type. If the parameter does not have a
829         user-defined or REF type, the typeName parameter is ignored.
830
831      * @params:
832        parameterIndex - the first parameter is 1, the second is 2, ...
833         sqlType - a value from java.sql.Types
834         typeName - the fully qualified name of an SQL UDT or the type name
835             of the SQL structured type being referenced by a REF type;
836               ignored if the parameter is not a UDT or REF type
837      **
838    public void setNull(int parameterIndex,int sqlType,String typeName)throws SQLException
839    {
840       rowSetProperties.setParameter(parameterIndex -1 ,null);
841    }
842
843    /**
844      * Sets the designated parameter in this RowSet object's command with
845      * a Java Object. For integral values, the java.lang equivalent objects
846      * should be used.
847      * The JDBC specification provides a standard mapping from Java Object
848      * types to SQL types. The driver will convert the given Java object to
849      * its standard SQL mapping before sending it to the database.
850
851       Note that this method may be used to pass datatabase-specific
852       abstract data types by using a driver-specific Java type.
853       If the object is of a class implementing SQLData, the rowset should
854       call the method SQLData.writeSQL to write the object to an SQLOutput
855       data stream. If the object is an instance of a class implementing the
856       Ref, Struct, Array, Blob, or Clob interfaces, the driver uses the
857       default mapping to the corresponding SQL type.
858
859      * An exception is thrown if there is an ambiguity, for example, if
860      * the object is of a class implementing more than one of these
861      * interfaces.
862
863      * @params:
864        parameterIndex - The first parameter is 1, the second is 2, ...
865                     x - The object containing the input parameter value
866      **
867    public void setObject(int parameterIndex,Object x) throws SQLException{
868       rowSetProperties.setParameter(parameterIndex -1,x);
869    }
870
871    /**
872      * Sets the designated parameter in this RowSet object's command with
873      * a Java Object. For integral values, the java.lang equivalent objects
874      * should be used. This method is like setObject above, but the scale
875      * used is the scale of the second parameter. Scalar values have a scale
876      * of zero. Literal values have the scale present in the literal.
877      * Even though it is supported, it is not recommended that this method
878      * be called with floating point input values.
879
880      * @params:
881            parameterIndex - the first parameter is 1, the second is 2, ...
882                        x - the object containing the input parameter value
883            targetSqlType - the SQL type (as defined in java.sql.Types) to be
884                sent to the database
885      **
886    public void setObject(int parameterIndex,Object x,int targetSqlType) throws SQLException
887    {
888      try{
889       Object value = TypeConverter.convertObject(x,targetSqlType);
890       rowSetProperties.setParameter(parameterIndex -1 ,value );
891      } catch (Exception e){
892         e.printStackTrace();
893      }
894    }
895
896    /**
897      * Sets the designated parameter in this RowSet object's command with
898      * the given Java Object. For integral values, the java.lang equivalent
899      * objects should be used (for example, an instance of the class Integer
900      * for an int).
901      * The given Java object will be converted to the targetSqlType before
902      * being sent to the database.
903
904      * If the object is of a class implementing SQLData, the rowset should
905      * call the method SQLData.writeSQL to write the object to an SQLOutput
906      * data stream. If the object is an instance of a class implementing the
907      * Ref, Struct, Array, Blob, or Clob interfaces, the driver uses the
908      * default mapping to the corresponding SQL type.
909
910        Note that this method may be used to pass datatabase-specific abstract
911          data types.
912
913      * @params:
914           parameterIndex - the first parameter is 1, the second is 2, ...
915                    x - the object containing the input parameter value
916           targetSqlType - the SQL type (as defined in java.sql.Types) to be
917              sent to the database. The scale argument may further qualify this
918               type.
919           scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types,
920                this is the number of digits after the decimal point.
921                For all other types, this value will be ignored.
922
923      **
924    public void setObject(int parameterIndex,Object x,int targetSqlType,int scale)
925          throws SQLException{
926     try{
927       Object value = TypeConverter.convertObject(x,targetSqlType);
928       if( targetSqlType == Types.DECIMAL || targetSqlType == Types.NUMERIC ){
929         rowSetProperties.setParameter(parameterIndex -1 ,value );
930       }
931       else
932         rowSetProperties.setParameter(parameterIndex -1 ,value );
933     }catch (Exception e){
934       e.printStackTrace();
935       }
936
937    }
938
939    public void updateArray(int columnIndex, java.sql.Array x) throws SQLException{
940      checkUpdatable();
941      super.updateArray(columnIndex, x);
942      fireRowChangeListeners();
943    }
944
945    public void updateArray(String columnName, java.sql.Array x) throws SQLException{
946      checkUpdatable();
947      super.updateArray(columnName, x);
948      fireRowChangeListeners();
949    }
950
951    public void updateAsciiStream(int columnIndex,InputStream x,int length) throws SQLException{
952      checkUpdatable();
953      super.updateAsciiStream(columnIndex, x,length);
954      fireRowChangeListeners();
955    }
956
957    public void updateAsciiStream(String columnName,InputStream x,int length) throws SQLException{
958      checkUpdatable();
959      super.updateAsciiStream(columnName, x , length);
960      fireRowChangeListeners();
961    }
962
963    public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException{
964      checkUpdatable();
965      super.updateBigDecimal(columnIndex, x);
966      fireRowChangeListeners();
967    }
968
969    public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException{
970      checkUpdatable();
971      super.updateBigDecimal(columnName, x);
972      fireRowChangeListeners();
973    }
974
975    public void updateBinaryStream(int columnIndex,java.io.InputStream x,int length) throws SQLException{
976      checkUpdatable();
977      super.updateBinaryStream(columnIndex, x, length);
978      fireRowChangeListeners();
979    }
980
981    public void updateBinaryStream(String columnName,java.io.InputStream x,int length) throws SQLException{
982      checkUpdatable();
983      super.updateBinaryStream(columnName, x, length);
984      fireRowChangeListeners();
985    }
986
987    public void updateBlob(int columnIndex, Blob x) throws SQLException{
988      checkUpdatable();
989      super.updateBlob(columnIndex, x);
990      fireRowChangeListeners();
991    }
992
993    public void updateBlob(String columnName, Blob x) throws SQLException{
994      checkUpdatable();
995      super.updateBlob(columnName, x);
996      fireRowChangeListeners();
997    }
998
999    public void updateBoolean(int columnIndex, boolean x) throws SQLException{
1000     checkUpdatable();
1001     super.updateBoolean(columnIndex, x);
1002     fireRowChangeListeners();
1003   }
1004
1005   public void updateBoolean(String columnName, boolean x) throws SQLException{
1006     checkUpdatable();
1007     super.updateBoolean(columnName, x);
1008     fireRowChangeListeners();
1009   }
1010
1011   public void updateByte(int columnIndex, byte x) throws SQLException{
1012     checkUpdatable();
1013     super.updateByte(columnIndex, x);
1014     fireRowChangeListeners();
1015   }
1016
1017   public void updateByte(String columnName, byte x) throws SQLException{
1018     checkUpdatable();
1019     super.updateByte(columnName, x);
1020     fireRowChangeListeners();
1021   }
1022
1023   public void updateBytes(int columnIndex, byte x[]) throws SQLException{
1024     checkUpdatable();
1025     super.updateBytes(columnIndex, x);
1026     fireRowChangeListeners();
1027   }
1028
1029   public void updateCharacterStream(int columnIndex,java.io.Reader x,int length) throws SQLException{
1030     checkUpdatable();
1031     super.updateCharacterStream(columnIndex, x,length);
1032     fireRowChangeListeners();
1033
1034   }
1035   public void updateCharacterStream(String columnName,java.io.Reader reader,int length) throws SQLException{
1036     checkUpdatable();
1037     super.updateCharacterStream(columnName, reader,length);
1038     fireRowChangeListeners();
1039   }
1040
1041   public void updateClob(int columnIndex, java.sql.Clob x) throws SQLException{
1042     checkUpdatable();
1043     super.updateClob(columnIndex, x);
1044     fireRowChangeListeners();
1045   }
1046   public void updateClob(String columnName, java.sql.Clob x) throws SQLException{
1047     checkUpdatable();
1048     super.updateClob(columnName, x);
1049     fireRowChangeListeners();
1050   }
1051   public void updateDate(int columnIndex, java.sql.Date x) throws SQLException{
1052     checkUpdatable();
1053     super.updateDate(columnIndex, x);
1054     fireRowChangeListeners();
1055   }
1056
1057   public void updateDate(String columnName, java.sql.Date x) throws SQLException{
1058     checkUpdatable();
1059     super.updateDate(columnName, x);
1060     fireRowChangeListeners();
1061   }
1062
1063   public void updateDouble(int columnIndex, double x) throws SQLException{
1064     checkUpdatable();
1065     super.updateDouble(columnIndex, x);
1066     fireRowChangeListeners();
1067   }
1068
1069   public void updateDouble(String columnName, double x) throws SQLException{
1070     checkUpdatable();
1071     super.updateDouble(columnName, x);
1072     fireRowChangeListeners();
1073   }
1074
1075   public void updateFloat(int columnIndex, float x) throws SQLException{
1076     checkUpdatable();
1077     super.updateFloat(columnIndex, x);
1078     fireRowChangeListeners();
1079   }
1080
1081   public void updateFloat(String columnName, float x) throws SQLException{
1082     checkUpdatable();
1083     super.updateFloat(columnName, x);
1084     fireRowChangeListeners();
1085   }
1086
1087   public void updateInt(int columnIndex, int x) throws SQLException{
1088     checkUpdatable();
1089     super.updateInt(columnIndex, x);
1090     fireRowChangeListeners();
1091   }
1092
1093   public void updateInt(String columnName, int x) throws SQLException{
1094     checkUpdatable();
1095     super.updateInt(columnName, x);
1096     fireRowChangeListeners();
1097   }
1098
1099   public void updateLong(int columnIndex, long x) throws SQLException{
1100     checkUpdatable();
1101     super.updateLong(columnIndex, x);
1102     fireRowChangeListeners();
1103   }
1104
1105   public void updateLong(String columnName, long x) throws SQLException{
1106     checkUpdatable();
1107     super.updateLong(columnName, x);
1108     fireRowChangeListeners();
1109   }
1110
1111   public void updateNull(int columnIndex) throws SQLException{
1112     checkUpdatable();
1113     super.updateNull(columnIndex);
1114     fireRowChangeListeners();
1115   }
1116
1117   public void updateNull(String columnName) throws SQLException{
1118     checkUpdatable();
1119     super.updateNull(columnName);
1120     fireRowChangeListeners();
1121   }
1122
1123   public void updateObject(int columnIndex, Object x) throws SQLException{
1124     checkUpdatable();
1125     super.updateObject(columnIndex, x);
1126     fireRowChangeListeners();
1127   }
1128
1129   public void updateObject(String columnName, Object x) throws SQLException{
1130     checkUpdatable();
1131     super.updateObject(columnName, x);
1132     fireRowChangeListeners();
1133   }
1134
1135   public void updateObject(int columnIndex, Object x, int scale) throws SQLException{
1136     checkUpdatable();
1137     super.updateObject(columnIndex, x);
1138     fireRowChangeListeners();
1139   }
1140
1141   public void updateObject(String columnName, Object x, int scale) throws SQLException{
1142     checkUpdatable();
1143     super.updateObject(columnName, x);
1144     fireRowChangeListeners();
1145   }
1146
1147   public void updateRow() throws SQLException{
1148      checkUpdatable();
1149      super.updateRow();
1150      fireRowChangeListeners();
1151   }
1152
1153   public void updateRef(int columnIndex, java.sql.Ref x) throws SQLException{
1154     checkUpdatable();
1155     super.updateRef(columnIndex, x);
1156     fireRowChangeListeners();
1157   }
1158   public void updateRef(String columnName, java.sql.Ref x) throws SQLException{
1159     checkUpdatable();
1160     super.updateRef(columnName, x);
1161     fireRowChangeListeners();
1162   }
1163
1164   public void updateShort(int columnIndex, short x) throws SQLException{
1165     checkUpdatable();
1166     super.updateShort(columnIndex, x);
1167     fireRowChangeListeners();
1168   }
1169
1170   public void updateShort(String columnName, short x) throws SQLException{
1171     checkUpdatable();
1172     super.updateShort(columnName, x);
1173     fireRowChangeListeners();
1174   }
1175
1176   public void updateString(int columnIndex, String x) throws SQLException{
1177     checkUpdatable();
1178     super.updateObject(columnIndex, x);
1179     fireRowChangeListeners();
1180   }
1181
1182   public void updateString(String columnName, String x) throws SQLException{
1183     checkUpdatable();
1184     super.updateString(columnName, x);
1185     fireRowChangeListeners();
1186   }
1187
1188   public void updateTime(int columnIndex, java.sql.Time x) throws SQLException{
1189     checkUpdatable();
1190     super.updateTime(columnIndex, x);
1191     fireRowChangeListeners();
1192   }
1193
1194   public void updateTime(String columnName, java.sql.Time x) throws SQLException{
1195     checkUpdatable();
1196     super.updateTime(columnName, x);
1197     fireRowChangeListeners();
1198   }
1199
1200   public void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws SQLException{
1201     checkUpdatable();
1202     super.updateTimestamp(columnIndex, x);
1203     fireRowChangeListeners();
1204   }
1205
1206   public void updateTimestamp(String columnName, java.sql.Timestamp x) throws SQLException{
1207     checkUpdatable();
1208     super.updateTimestamp(columnName, x);
1209     fireRowChangeListeners();
1210   }
1211
1212   private void checkUpdatable() throws SQLException{
1213     if( isReadOnly() )
1214       throw new SQLException(ResourceManager.dserrors.getString("DSE883"));
1215   }
1216
1217   private void fireRowChangeListeners() {
1218      for(int i = 0 ; i < rowListeners.size() ; i++ ) {
1219         RowSetListener listener = (RowSetListener) rowListeners.get(i);
1220         listener.rowChanged(new RowSetEvent(this));
1221      }
1222   }
1223
1224   private void fireRowSetChangeListeners() {
1225      for(int i = 0 ; i < rowListeners.size() ; i++ ) {
1226         RowSetListener listener = (RowSetListener) rowListeners.get(i);
1227         listener.rowSetChanged(new RowSetEvent(this));
1228      }
1229   }
1230
1231   private void fireCursorMovedListeners() {
1232      for(int i = 0 ; i < rowListeners.size() ; i++ ) {
1233         RowSetListener listener = (RowSetListener) rowListeners.get(i);
1234         listener.cursorMoved(new RowSetEvent(this));
1235      }
1236   }
1237
1238   /* Navigation Methods *
1239   public boolean absolute( int row ) throws SQLException{
1240      boolean b = super.absolute(row);
1241      if(b)
1242         fireCursorMovedListeners();
1243      return b;
1244   }
1245
1246   public void afterLast() throws SQLException{
1247      super.afterLast();
1248      fireCursorMovedListeners();
1249   }
1250
1251   public void beforeFirst() throws SQLException{
1252      super.beforeFirst();
1253      fireCursorMovedListeners();
1254   }
1255
1256   public boolean first() throws SQLException{
1257      boolean b = super.first();
1258      if(b)
1259         fireCursorMovedListeners();
1260      return b;
1261   }
1262
1263   public boolean last() throws SQLException{
1264      boolean b = super.last();
1265      if(b)
1266         fireCursorMovedListeners();
1267      return b;
1268   }
1269
1270   public void moveToCurrentRow() throws SQLException{
1271      super.moveToCurrentRow();
1272      fireCursorMovedListeners();
1273   }
1274
1275   public boolean next() throws SQLException{
1276      boolean b = super.next();
1277      if(b)
1278         fireCursorMovedListeners();
1279      return b;
1280   }
1281
1282   public boolean previous() throws SQLException{
1283      boolean b = super.previous();
1284      if(b)
1285         fireCursorMovedListeners();
1286      return b;
1287   }
1288
1289   public boolean relative( int rows ) throws SQLException{
1290      boolean b = super.relative(rows);
1291      if(b)
1292         fireCursorMovedListeners();
1293      return b;
1294   }
1295
1296  /**
1297    *Retrieves the parameters that have been set for this RowSet object's
1298    * command.
1299
1300    * @returns:
1301             an array of the current parameter values for this RowSet
1302               object's command
1303    **
1304
1305  public Object[] getParams() throws SQLException{
1306     return rowSetProperties.getParameters();
1307  }
1308
1309
1310  /**
1311    * Retrieves the Connection object that was passed to this RowSet object.
1312
1313    * @returns:
1314         the Connection object passed to the rowset or null if none
1315            was passed
1316 *
1317  public Connection getConnection() throws SQLException {
1318     return null;
1319  }
1320
1321
1322  /**
1323    * Sets the given RowSetMetaData object as the RowSetMetaData object for
1324    * this RowSet object. The RowSetReader object associated with the rowset
1325    * will use RowSetMetaData methods to set the values giving information
1326    * about the rowset's columns.
1327
1328    * @parameters:
1329        md - the RowSetMetaData object that will be set with information
1330         about the rowset's columns
1331    **
1332  public void setMetaData(RowSetMetaData md) throws SQLException{
1333     rowSetMetaData = md;
1334  }
1335
1336
1337  /**
1338    * Retrieves a ResultSet object containing the original value of this RowSet
1339    * object.
1340    * The cursor is positioned before the first row in the result set.
1341    * Only rows contained in the result set returned by the method getOriginal
1342    * are said to have an original value.
1343
1344    * @returns:
1345         the original value of the rowset
1346    **
1347
1348  public ResultSet getOriginal() throws SQLException{
1349     return null;
1350  }
1351
1352  /**
1353    * Retrieves a ResultSet object containing the original value of the current
1354    * row only. If the current row has no original value, an empty result set
1355    * is returned. If there is no current row, an exception is thrown.
1356
1357    * @returns:
1358        the original value of the current row as a ResultSet object
1359    Throws:
1360        SQLException - if a database access error occurs or this method is
1361           called while the cursor is on the insert row, before the first
1362            row, or after the last row
1363 *
1364  public ResultSet getOriginalRow() throws SQLException{
1365     return null;
1366  }
1367
1368
1369
1370   class DRowSetProperties {
1371      public ArrayList parameterList;
1372      public String userName;
1373      public String url;
1374      public String password;
1375      public int queryTimeout;
1376      public boolean isReadOnly = false;
1377      public int maxRows;
1378      public int maxFieldSize;
1379      public int transactionIsolation;
1380      public Map typeMap ;
1381      public String cmd;
1382      public String dataSourceName;
1383      public boolean escapeProcessing = true;
1384      public int concurrency = CONCUR_READ_ONLY;//1007;
1385      public int type = TYPE_FORWARD_ONLY;//1003;
1386      public DRowSetProperties() {}
1387
1388      public void clearAll() {
1389         parameterList = null;
1390      }
1391
1392      public void setParameter(int parameterIndex,Object value){
1393         if(parameterList == null)
1394           parameterList = new ArrayList();
1395         int size = parameterList.size();
1396         if(size <= parameterIndex ){
1397           for(int i = size ; i<= parameterIndex ; i++)
1398              parameterList.add(null);
1399         }
1400         if(value != null)
1401          parameterList.add(parameterIndex,value);
1402      }
1403
1404      public Object [] getParameters(){
1405         return parameterList == null ? null : parameterList.toArray();
1406      }
1407
1408   }
1409*/

1410}
1411
Popular Tags