KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > jdbc > EmbedCallableStatement20


1 /*
2
3    Derby - Class org.apache.derby.impl.jdbc.EmbedCallableStatement20
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.jdbc;
23
24 import java.math.BigDecimal JavaDoc;
25 import java.sql.CallableStatement JavaDoc;
26 import java.sql.SQLException JavaDoc;
27 import java.sql.Date JavaDoc;
28 import java.sql.Time JavaDoc;
29 import java.sql.Timestamp JavaDoc;
30 import java.sql.Types JavaDoc;
31
32 /* ---- New jdbc 2.0 types ----- */
33 import java.sql.Array JavaDoc;
34 import java.sql.Blob JavaDoc;
35 import java.sql.Clob JavaDoc;
36 import java.sql.Ref JavaDoc;
37
38 import java.net.URL JavaDoc;
39 import java.util.Map JavaDoc;
40
41 import java.io.ByteArrayInputStream JavaDoc;
42 import java.io.InputStream JavaDoc;
43 import java.io.InputStreamReader JavaDoc;
44 import java.io.Reader JavaDoc;
45 import java.io.StringReader JavaDoc;
46 import java.io.UnsupportedEncodingException JavaDoc;
47
48 import java.util.Calendar JavaDoc;
49
50 import org.apache.derby.iapi.error.StandardException;
51
52 import org.apache.derby.iapi.services.io.StreamStorable;
53 import org.apache.derby.iapi.sql.conn.StatementContext;
54 import org.apache.derby.iapi.reference.JDBC30Translation;
55 import org.apache.derby.iapi.reference.SQLState;
56 import org.apache.derby.iapi.types.DataValueDescriptor;
57
58 import org.apache.derby.impl.jdbc.Util;
59 import org.apache.derby.impl.jdbc.EmbedConnection;
60 import org.apache.derby.impl.jdbc.EmbedResultSet;
61
62
63 /**
64  * This class extends the EmbedCallableStatement class in order to support new
65  * methods and classes that come with JDBC 2.0.
66  *
67  * @see org.apache.derby.impl.jdbc.EmbedCallableStatement
68  *
69  * @author francois
70  */

71 public class EmbedCallableStatement20
72     extends org.apache.derby.impl.jdbc.EmbedCallableStatement
73 {
74
75     //////////////////////////////////////////////////////////////
76
//
77
// CONSTRUCTORS
78
//
79
//////////////////////////////////////////////////////////////
80
public EmbedCallableStatement20 (EmbedConnection conn, String JavaDoc sql,
81                                    int resultSetType,
82                                    int resultSetConcurrency,
83                                    int resultSetHoldability)
84         throws SQLException JavaDoc
85     {
86         super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability);
87     }
88
89     /////////////////////////////////////////////////////////////////////////
90
//
91
// JDBC 2.0 - New public methods
92
//
93
/////////////////////////////////////////////////////////////////////////
94

95     /**
96      * JDBC 2.0
97      *
98      * Get the value of a NUMERIC parameter as a java.math.BigDecimal object.
99      *
100      * @param parameterIndex the first parameter is 1, the second is 2, ...
101      * @return the parameter value (full precision); if the value is SQL NULL,
102      * the result is null
103      * @exception SQLException if a database-access error occurs.
104      */

105     public BigDecimal JavaDoc getBigDecimal(int parameterIndex) throws SQLException JavaDoc
106     {
107         checkStatus();
108         try {
109             DataValueDescriptor dvd = getParms().getParameterForGet(parameterIndex-1);
110             if (wasNull = dvd.isNull())
111                 return null;
112             
113             return org.apache.derby.iapi.types.SQLDecimal.getBigDecimal(dvd);
114             
115         } catch (StandardException e)
116         {
117             throw EmbedResultSet.noStateChangeException(e);
118         }
119     }
120
121
122     /**
123      * JDBC 2.0
124      *
125      * Returns an object representing the value of OUT parameter @i.
126      * Use the @map to determine the class from which to construct
127      * data of SQL structured and distinct types.
128      *
129      * @param i the first parameter is 1, the second is 2, ...
130      * @param map the mapping from SQL type names to Java classes
131      * @return a java.lang.Object holding the OUT parameter value.
132      * @exception SQLException if a database-access error occurs.
133      */

134     public Object JavaDoc getObject (int i, java.util.Map JavaDoc map) throws SQLException JavaDoc
135     {
136         checkStatus();
137         if( map == null)
138             throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map",
139                                               "java.sql.CallableStatement.getObject");
140         if(!(map.isEmpty()))
141             throw Util.notImplemented();
142         // Map is empty call the normal getObject method.
143
return getObject(i);
144     }
145
146     /**
147      * JDBC 2.0
148      *
149      * Get a REF(<structured-type>) OUT parameter.
150      *
151      * @param i the first parameter is 1, the second is 2, ...
152      * @return an object representing data of an SQL REF Type
153      * @exception SQLException if a database-access error occurs.
154      */

155     public Ref JavaDoc getRef (int i) throws SQLException JavaDoc {
156         throw Util.notImplemented();
157     }
158
159     /**
160      * JDBC 2.0
161      *
162      * Get an Array OUT parameter.
163      *
164      * @param i the first parameter is 1, the second is 2, ...
165      * @return an object representing an SQL array
166      * @exception SQLException if a database-access error occurs.
167      */

168     public Array JavaDoc getArray (int i) throws SQLException JavaDoc {
169         throw Util.notImplemented();
170     }
171
172
173  
174     /*
175      * Note: all the JDBC 2.0 Prepared statement methods are duplicated in here
176      * because this class inherits from Local/EmbedCallableStatement, which
177      * inherits from local/PreparedStatement. This class should inherit from a
178      * local20/PreparedStatement. Since java does not allow multiple inheritance,
179      * duplicate the code here.
180      */

181  
182      /**
183       * JDBC 2.0
184       *
185       * Set a REF(<structured-type>) parameter.
186       *
187       * @param i the first parameter is 1, the second is 2, ...
188       * @param x an object representing data of an SQL REF Type
189       * @exception SQLException Feature not implemented for now.
190       */

191      public void setRef (int i, Ref JavaDoc x) throws SQLException JavaDoc {
192         throw Util.notImplemented();
193      }
194  
195      /**
196       * JDBC 2.0
197       *
198       * Set an Array parameter.
199       *
200       * @param i the first parameter is 1, the second is 2, ...
201       * @param x an object representing an SQL array
202       * @exception SQLException Feature not implemented for now.
203       */

204      public void setArray (int i, Array JavaDoc x) throws SQLException JavaDoc {
205         throw Util.notImplemented();
206      }
207  
208
209     /////////////////////////////////////////////////////////////////////////
210
//
211
// JDBC 3.0 - New public methods
212
//
213
/////////////////////////////////////////////////////////////////////////
214

215     /**
216     * JDBC 3.0
217     *
218     * Registers the OUT parameter named parameterName to the JDBC type sqlType.
219     * All OUT parameters must be registered before a stored procedure is executed.
220     *
221     * @param parameterName - the name of the parameter
222     * @param sqlType - the JDBC type code defined by java.sql.Types. If the
223     * parameter is of JDBC type NUMERIC or DECIMAL, the version of registerOutParameter
224     * that accepts a scale value should be used.
225     * @exception SQLException Feature not implemented for now.
226     */

227     public void registerOutParameter(String JavaDoc parameterName,
228                     int sqlType)
229     throws SQLException JavaDoc
230     {
231         throw Util.notImplemented();
232     }
233
234     /**
235     * JDBC 3.0
236     *
237     * Registers the designated output parameter. This version of the method
238     * registerOutParameter should be used for a user-named or REF output parameter.
239     *
240     * @param parameterName - the name of the parameter
241     * @param sqlType - the SQL type code defined by java.sql.Types.
242     * @param typeName - the fully-qualified name of an SQL structure type
243     * @exception SQLException Feature not implemented for now.
244     */

245     public void registerOutParameter(String JavaDoc parameterName,
246                     int sqlType, String JavaDoc typeName)
247     throws SQLException JavaDoc
248     {
249         throw Util.notImplemented();
250     }
251
252     /**
253     * JDBC 3.0
254     *
255     * Registers the parameter named parameterName to the JDBC type sqlType.
256     * This method must be called before a stored procedure is executed.
257     *
258     * @param parameterName - the name of the parameter
259     * @param sqlType - the SQL type code defined by java.sql.Types.
260     * @param scale - the desired number of digits to the right of the decimal point.
261     * It must be greater than or equal to zero.
262     * @exception SQLException Feature not implemented for now.
263     */

264     public void registerOutParameter(String JavaDoc parameterName,
265                     int sqlType, int scale)
266     throws SQLException JavaDoc
267     {
268         throw Util.notImplemented();
269     }
270
271     /**
272     * JDBC 3.0
273     *
274     * Retrieves the value of a JDBC REF (<structured-type) parameter as a Ref object
275     * in the Java programming language.
276     *
277     * @param parameterName - the name of the parameter
278     * @return the parameter value as a Ref object in the Java Programming language.
279     * If the value is SQL NULL, the result is null.
280     * @exception SQLException Feature not implemented for now.
281     */

282     public Ref JavaDoc getRef(String JavaDoc parameterName)
283     throws SQLException JavaDoc
284     {
285         throw Util.notImplemented();
286     }
287
288     /**
289     * JDBC 3.0
290     *
291     * Retrieves the value of a JDBC BLOB parameter as a Blob object
292     * in the Java programming language.
293     *
294     * @param parameterName - the name of the parameter
295     * @return the parameter value as a Blob object in the Java Programming language.
296     * If the value is SQL NULL, the result is null.
297     * @exception SQLException Feature not implemented for now.
298     */

299     public Blob JavaDoc getBlob(String JavaDoc parameterName)
300     throws SQLException JavaDoc
301     {
302         throw Util.notImplemented();
303     }
304
305     /**
306     * JDBC 3.0
307     *
308     * Retrieves the value of a JDBC CLOB parameter as a Clob object
309     * in the Java programming language.
310     *
311     * @param parameterName - the name of the parameter
312     * @return the parameter value as a Clob object in the Java Programming language.
313     * If the value is SQL NULL, the result is null.
314     * @exception SQLException Feature not implemented for now.
315     */

316     public Clob JavaDoc getClob(String JavaDoc parameterName)
317     throws SQLException JavaDoc
318     {
319         throw Util.notImplemented();
320     }
321
322     /**
323     * JDBC 3.0
324     *
325     * Retrieves the value of a JDBC ARRAY parameter as an Array object
326     * in the Java programming language.
327     *
328     * @param parameterName - the name of the parameter
329     * @return the parameter value as a Array object in the Java Programming language.
330     * If the value is SQL NULL, the result is null.
331     * @exception SQLException Feature not implemented for now.
332     */

333     public Array JavaDoc getArray(String JavaDoc parameterName)
334     throws SQLException JavaDoc
335     {
336         throw Util.notImplemented();
337     }
338
339     /**
340     * JDBC 3.0
341     *
342     * Sets the designated parameter to SQL NULL.
343     *
344     * @param parameterName - the name of the parameter
345     * @param sqlType - the SQL type code defined in java.sql.Types
346     * @exception SQLException Feature not implemented for now.
347     */

348     public void setNull(String JavaDoc parameterName, int sqlType)
349     throws SQLException JavaDoc
350     {
351         throw Util.notImplemented();
352     }
353     /**
354     * JDBC 3.0
355     *
356     * Sets the designated parameter to SQL NULL.
357     *
358     * @param parameterName - the name of the parameter
359     * @param sqlType - the SQL type code defined in java.sql.Types
360     * @param typeName - the fully-qualified name of an SQL user-defined type
361     * @exception SQLException Feature not implemented for now.
362     */

363     public void setNull(String JavaDoc parameterName, int sqlType, String JavaDoc typeName)
364     throws SQLException JavaDoc
365     {
366         throw Util.notImplemented();
367     }
368
369     /**
370     * JDBC 3.0
371     *
372     * Sets the designated parameter to the given Java boolean value. The driver
373     * converts this to an SQL BIT value when it sends it to the database.
374     *
375     * @param parameterName - the name of the parameter
376     * @param x - the parameter value
377     * @exception SQLException Feature not implemented for now.
378     */

379     public void setBoolean(String JavaDoc parameterName, boolean x)
380     throws SQLException JavaDoc
381     {
382         throw Util.notImplemented();
383     }
384
385     /**
386     * JDBC 3.0
387     *
388     * Retrieves the value of a JDBC BIT parameter as a boolean in the Java
389     * programming language.
390     *
391     * @param parameterName - the name of the parameter
392     * @return the parameter value. If the value is SQL NULL, the result is false.
393     * @exception SQLException Feature not implemented for now.
394     */

395     public boolean getBoolean(String JavaDoc parameterName)
396     throws SQLException JavaDoc
397     {
398         throw Util.notImplemented();
399     }
400
401     /**
402     * JDBC 3.0
403     *
404     * Sets the designated parameter to the given Java byte value. The driver
405     * converts this to an SQL TINYINT value when it sends it to the database.
406     *
407     * @param parameterName - the name of the parameter
408     * @param x - the parameter value
409     * @exception SQLException Feature not implemented for now.
410     */

411     public void setByte(String JavaDoc parameterName, byte x)
412     throws SQLException JavaDoc
413     {
414         throw Util.notImplemented();
415     }
416
417     /**
418     * JDBC 3.0
419     *
420     * Retrieves the value of a JDBC TINYINT parameter as a byte in the Java
421     * programming language.
422     *
423     * @param parameterName - the name of the parameter
424     * @return the parameter value. If the value is SQL NULL, the result is 0.
425     * @exception SQLException Feature not implemented for now.
426     */

427     public byte getByte(String JavaDoc parameterName)
428     throws SQLException JavaDoc
429     {
430         throw Util.notImplemented();
431     }
432
433     /**
434     * JDBC 3.0
435     *
436     * Sets the designated parameter to the given Java short value. The driver
437     * converts this to an SQL SMALLINT value when it sends it to the database.
438     *
439     * @param parameterName - the name of the parameter
440     * @param x - the parameter value
441     * @exception SQLException Feature not implemented for now.
442     */

443     public void setShort(String JavaDoc parameterName, short x)
444     throws SQLException JavaDoc
445     {
446         throw Util.notImplemented();
447     }
448
449     /**
450     * JDBC 3.0
451     *
452     * Retrieves the value of a JDBC SMALLINT parameter as a short in the Java
453     * programming language.
454     *
455     * @param parameterName - the name of the parameter
456     * @return the parameter value. If the value is SQL NULL, the result is 0.
457     * @exception SQLException Feature not implemented for now.
458     */

459     public short getShort(String JavaDoc parameterName)
460     throws SQLException JavaDoc
461     {
462         throw Util.notImplemented();
463     }
464
465     /**
466     * JDBC 3.0
467     *
468     * Sets the designated parameter to the given Java int value. The driver
469     * converts this to an SQL INTEGER value when it sends it to the database.
470     *
471     * @param parameterName - the name of the parameter
472     * @param x - the parameter value
473     * @exception SQLException Feature not implemented for now.
474     */

475     public void setInt(String JavaDoc parameterName, int x)
476     throws SQLException JavaDoc
477     {
478         throw Util.notImplemented();
479     }
480
481     /**
482     * JDBC 3.0
483     *
484     * Retrieves the value of a JDBC INTEGER parameter as a int in the Java
485     * programming language.
486     *
487     * @param parameterName - the name of the parameter
488     * @return the parameter value. If the value is SQL NULL, the result is 0.
489     * @exception SQLException Feature not implemented for now.
490     */

491     public int getInt(String JavaDoc parameterName)
492     throws SQLException JavaDoc
493     {
494         throw Util.notImplemented();
495     }
496
497     /**
498     * JDBC 3.0
499     *
500     * Sets the designated parameter to the given Java long value. The driver
501     * converts this to an SQL BIGINT value when it sends it to the database.
502     *
503     * @param parameterName - the name of the parameter
504     * @param x - the parameter value
505     * @exception SQLException Feature not implemented for now.
506     */

507     public void setLong(String JavaDoc parameterName, long x)
508     throws SQLException JavaDoc
509     {
510         throw Util.notImplemented();
511     }
512
513     /**
514     * JDBC 3.0
515     *
516     * Retrieves the value of a JDBC BIGINT parameter as a long in the Java
517     * programming language.
518     *
519     * @param parameterName - the name of the parameter
520     * @return the parameter value. If the value is SQL NULL, the result is 0.
521     * @exception SQLException Feature not implemented for now.
522     */

523     public long getLong(String JavaDoc parameterName)
524     throws SQLException JavaDoc
525     {
526         throw Util.notImplemented();
527     }
528
529     /**
530     * JDBC 3.0
531     *
532     * Sets the designated parameter to the given Java float value. The driver
533     * converts this to an SQL FLOAT value when it sends it to the database.
534     *
535     * @param parameterName - the name of the parameter
536     * @param x - the parameter value
537     * @exception SQLException Feature not implemented for now.
538     */

539     public void setFloat(String JavaDoc parameterName, float x)
540     throws SQLException JavaDoc
541     {
542         throw Util.notImplemented();
543     }
544
545     /**
546     * JDBC 3.0
547     *
548     * Retrieves the value of a JDBC FLOAT parameter as a float in the Java
549     * programming language.
550     *
551     * @param parameterName - the name of the parameter
552     * @return the parameter value. If the value is SQL NULL, the result is 0.
553     * @exception SQLException Feature not implemented for now.
554     */

555     public float getFloat(String JavaDoc parameterName)
556     throws SQLException JavaDoc
557     {
558         throw Util.notImplemented();
559     }
560
561     /**
562     * JDBC 3.0
563     *
564     * Sets the designated parameter to the given Java double value. The driver
565     * converts this to an SQL DOUBLE value when it sends it to the database.
566     *
567     * @param parameterName - the name of the parameter
568     * @param x - the parameter value
569     * @exception SQLException Feature not implemented for now.
570     */

571     public void setDouble(String JavaDoc parameterName, double x)
572     throws SQLException JavaDoc
573     {
574         throw Util.notImplemented();
575     }
576
577     /**
578     * JDBC 3.0
579     *
580     * Retrieves the value of a JDBC DOUBLE parameter as a double in the Java
581     * programming language.
582     *
583     * @param parameterName - the name of the parameter
584     * @return the parameter value. If the value is SQL NULL, the result is 0.
585     * @exception SQLException Feature not implemented for now.
586     */

587     public double getDouble(String JavaDoc parameterName)
588     throws SQLException JavaDoc
589     {
590         throw Util.notImplemented();
591     }
592
593     /**
594     * JDBC 3.0
595     *
596     * Sets the designated parameter to the given java.math.BigDecimal value. The driver
597     * converts this to an SQL NUMERIC value when it sends it to the database.
598     *
599     * @param parameterName - the name of the parameter
600     * @param x - the parameter value
601     * @exception SQLException Feature not implemented for now.
602     */

603     public void setBigDecimal(String JavaDoc parameterName, BigDecimal JavaDoc x)
604     throws SQLException JavaDoc
605     {
606         throw Util.notImplemented();
607     }
608
609     /**
610     * JDBC 3.0
611     *
612     * Retrieves the value of a JDBC NUMERIC parameter as a java.math.BigDecimal
613     * object with as many digits to the right of the decimal point as the value contains
614     *
615     * @param parameterName - the name of the parameter
616     * @return the parameter value. If the value is SQL NULL, the result is 0.
617     * @exception SQLException Feature not implemented for now.
618     */

619     public BigDecimal JavaDoc getBigDecimal(String JavaDoc parameterName)
620     throws SQLException JavaDoc
621     {
622         throw Util.notImplemented();
623     }
624
625     /**
626     * JDBC 3.0
627     *
628     * Sets the designated parameter to the given Java String value. The driver
629     * converts this to an SQL VARCHAR OR LONGVARCHAR value (depending on the
630     * argument's size relative the driver's limits on VARCHAR values) when it
631     * sends it to the database.
632     *
633     * @param parameterName - the name of the parameter
634     * @param x - the parameter value
635     * @exception SQLException Feature not implemented for now.
636     */

637     public void setString(String JavaDoc parameterName, String JavaDoc x)
638     throws SQLException JavaDoc
639     {
640         throw Util.notImplemented();
641     }
642
643     /**
644     * JDBC 3.0
645     *
646     * Retrieves the value of a JDBC CHAR, VARCHAR, or LONGVARCHAR parameter as
647     * a String in the Java programming language.
648     *
649     * @param parameterName - the name of the parameter
650     * @return the parameter value. If the value is SQL NULL, the result is null.
651     * @exception SQLException Feature not implemented for now.
652     */

653     public String JavaDoc getString(String JavaDoc parameterName)
654     throws SQLException JavaDoc
655     {
656         throw Util.notImplemented();
657     }
658
659     /**
660     * JDBC 3.0
661     *
662     * Sets the designated parameter to the given Java array of bytes. The driver
663     * converts this to an SQL VARBINARY OR LONGVARBINARY (depending on the argument's
664     * size relative to the driver's limits on VARBINARY values)when it sends it to
665     * the database.
666     *
667     * @param parameterName - the name of the parameter
668     * @param x - the parameter value
669     * @exception SQLException Feature not implemented for now.
670     */

671     public void setBytes(String JavaDoc parameterName, byte[] x)
672     throws SQLException JavaDoc
673     {
674         throw Util.notImplemented();
675     }
676
677     /**
678     * JDBC 3.0
679     *
680     * Retrieves the value of a JDBC BINARY or VARBINARY parameter as an array
681     * of byte values in the Java programming language.
682     *
683     * @param parameterName - the name of the parameter
684     * @return the parameter value. If the value is SQL NULL, the result is null.
685     * @exception SQLException Feature not implemented for now.
686     */

687     public byte[] getBytes(String JavaDoc parameterName)
688     throws SQLException JavaDoc
689     {
690         throw Util.notImplemented();
691     }
692
693     /**
694     * JDBC 3.0
695     *
696     * Sets the designated parameter to the given java.sql.Date value. The driver
697     * converts this to an SQL DATE value when it sends it to the database.
698     *
699     * @param parameterName - the name of the parameter
700     * @param x - the parameter value
701     * @exception SQLException Feature not implemented for now.
702     */

703     public void setDate(String JavaDoc parameterName, Date JavaDoc x)
704     throws SQLException JavaDoc
705     {
706         throw Util.notImplemented();
707     }
708
709     /**
710     * JDBC 3.0
711     *
712     * Sets the designated parameter to the given java.sql.Date value, using the given
713     * Calendar object.
714     *
715     * @param parameterName - the name of the parameter
716     * @param x - the parameter value
717     * @param cal - the Calendar object the driver will use to construct the date
718     * @exception SQLException Feature not implemented for now.
719     */

720     public void setDate(String JavaDoc parameterName, Date JavaDoc x, Calendar JavaDoc cal)
721     throws SQLException JavaDoc
722     {
723         throw Util.notImplemented();
724     }
725
726     /**
727     * JDBC 3.0
728     *
729     * Retrieves the value of a JDBC DATE parameter as ajava.sql.Date object
730     *
731     * @param parameterName - the name of the parameter
732     * @return the parameter value. If the value is SQL NULL, the result is null.
733     * @exception SQLException Feature not implemented for now.
734     */

735     public Date JavaDoc getDate(String JavaDoc parameterName)
736     throws SQLException JavaDoc
737     {
738         throw Util.notImplemented();
739     }
740
741     /**
742     * JDBC 3.0
743     *
744     * Retrieves the value of a JDBC DATE parameter as a java.sql.Date object,
745     * using the given Calendar object to construct the date object.
746     *
747     * @param parameterName - the name of the parameter
748     * @param cal - the Calendar object the driver will use to construct the date
749     * @return the parameter value. If the value is SQL NULL, the result is null.
750     * @exception SQLException Feature not implemented for now.
751     */

752     public Date JavaDoc getDate(String JavaDoc parameterName, Calendar JavaDoc cal)
753     throws SQLException JavaDoc
754     {
755         throw Util.notImplemented();
756     }
757
758     /**
759     * JDBC 3.0
760     *
761     * Sets the designated parameter to the given java.sql.Time value. The driver
762     * converts this to an SQL TIME value when it sends it to the database.
763     *
764     * @param parameterName - the name of the parameter
765     * @param x - the parameter value
766     * @exception SQLException Feature not implemented for now.
767     */

768     public void setTime(String JavaDoc parameterName, Time JavaDoc x)
769     throws SQLException JavaDoc
770     {
771         throw Util.notImplemented();
772     }
773
774     /**
775     * JDBC 3.0
776     *
777     * Retrieves the value of a JDBC TIME parameter as ajava.sql.Time object
778     *
779     * @param parameterName - the name of the parameter
780     * @return the parameter value. If the value is SQL NULL, the result is null.
781     * @exception SQLException Feature not implemented for now.
782     */

783     public Time JavaDoc getTime(String JavaDoc parameterName)
784     throws SQLException JavaDoc
785     {
786         throw Util.notImplemented();
787     }
788
789     /**
790     * JDBC 3.0
791     *
792     * Retrieves the value of a JDBC TIME parameter as a java.sql.Time object,
793     * using the given Calendar object to construct the time object.
794     *
795     * @param parameterName - the name of the parameter
796     * @param cal - the Calendar object the driver will use to construct the time
797     * @return the parameter value. If the value is SQL NULL, the result is null.
798     * @exception SQLException Feature not implemented for now.
799     */

800     public Time JavaDoc getTime(String JavaDoc parameterName, Calendar JavaDoc cal)
801     throws SQLException JavaDoc
802     {
803         throw Util.notImplemented();
804     }
805
806     /**
807     * JDBC 3.0
808     *
809     * Sets the designated parameter to the given java.sql.Time value using the
810     * Calendar object
811     *
812     * @param parameterName - the name of the parameter
813     * @param x - the parameter value
814     * @param cal - the Calendar object the driver will use to construct the time
815     * @exception SQLException Feature not implemented for now.
816     */

817     public void setTime(String JavaDoc parameterName, Time JavaDoc x, Calendar JavaDoc cal)
818     throws SQLException JavaDoc
819     {
820         throw Util.notImplemented();
821     }
822
823     /**
824     * JDBC 3.0
825     *
826     * Sets the designated parameter to the given java.sql.Timestamp value. The driver
827     * converts this to an SQL TIMESTAMP value when it sends it to the database.
828     *
829     * @param parameterName - the name of the parameter
830     * @param x - the parameter value
831     * @exception SQLException Feature not implemented for now.
832     */

833     public void setTimestamp(String JavaDoc parameterName, Timestamp JavaDoc x)
834     throws SQLException JavaDoc
835     {
836         throw Util.notImplemented();
837     }
838
839     /**
840     * JDBC 3.0
841     *
842     * Sets the designated parameter to the given java.sql.Timestamp value, using the
843     * given Calendar object
844     *
845     * @param parameterName - the name of the parameter
846     * @param x - the parameter value
847     * @param cal - the Calendar object the driver will use to construct the timestamp.
848     * @exception SQLException Feature not implemented for now.
849     */

850     public void setTimestamp(String JavaDoc parameterName, Timestamp JavaDoc x, Calendar JavaDoc cal)
851     throws SQLException JavaDoc
852     {
853         throw Util.notImplemented();
854     }
855
856     /**
857     * JDBC 3.0
858     *
859     * Retrieves the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp object
860     *
861     * @param parameterName - the name of the parameter
862     * @return the parameter value. If the value is SQL NULL, the result is null.
863     * @exception SQLException Feature not implemented for now.
864     */

865     public Timestamp JavaDoc getTimestamp(String JavaDoc parameterName)
866     throws SQLException JavaDoc
867     {
868         throw Util.notImplemented();
869     }
870
871     /**
872     * JDBC 3.0
873     *
874     * Retrieves the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp object,
875     * using the given Calendar object to construct the Timestamp object.
876     *
877     * @param parameterName - the name of the parameter
878     * @param cal - the Calendar object the driver will use to construct the Timestamp
879     * @return the parameter value. If the value is SQL NULL, the result is null.
880     * @exception SQLException Feature not implemented for now.
881     */

882     public Timestamp JavaDoc getTimestamp(String JavaDoc parameterName, Calendar JavaDoc cal)
883     throws SQLException JavaDoc
884     {
885         throw Util.notImplemented();
886     }
887
888     /**
889     * JDBC 3.0
890     *
891     * Sets the designated parameter to the given input stream, which will have the
892     * specified number of bytes.
893     *
894     * @param parameterName - the name of the parameter
895     * @param x - the Java input stream that contains the ASCII parameter value
896     * @param length - the number of bytes in the stream
897     * @exception SQLException Feature not implemented for now.
898     */

899     public void setAsciiStream(String JavaDoc parameterName, InputStream JavaDoc x, int length)
900     throws SQLException JavaDoc
901     {
902         throw Util.notImplemented();
903     }
904
905     /**
906     * JDBC 3.0
907     *
908     * Sets the designated parameter to the given input stream, which will have the
909     * specified number of bytes.
910     *
911     * @param parameterName - the name of the parameter
912     * @param x - the Java input stream that contains the binary parameter value
913     * @param length - the number of bytes in the stream
914     * @exception SQLException Feature not implemented for now.
915     */

916     public void setBinaryStream(String JavaDoc parameterName, InputStream JavaDoc x, int length)
917     throws SQLException JavaDoc
918     {
919         throw Util.notImplemented();
920     }
921
922     /**
923     * JDBC 3.0
924     *
925     * Sets the designated parameter to the given Reader object, which is the given
926     * number of characters long.
927     *
928     * @param parameterName - the name of the parameter
929     * @param reader - the java.io.Reader object that contains the UNICODE data
930     * @param length - the number of characters in the stream
931     * @exception SQLException Feature not implemented for now.
932     */

933     public void setCharacterStream(String JavaDoc parameterName, Reader JavaDoc reader, int length)
934     throws SQLException JavaDoc
935     {
936         throw Util.notImplemented();
937     }
938
939     /**
940     * JDBC 3.0
941     *
942     * Sets the value of the designated parameter with the given object. The second
943     * argument must be an object type; for integral values, the java.lang equivalent
944     * objects should be used.
945     *
946     * @param parameterName - the name of the parameter
947     * @param x - the object containing the input parameter value
948     * @param targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to
949     * the database. The scale argument may further qualify this type.
950     * @param scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this
951     * is the number of digits after the decimal point. For all other types, this value
952     * will be ignored.
953     * @exception SQLException Feature not implemented for now.
954     */

955     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType, int scale)
956     throws SQLException JavaDoc
957     {
958         throw Util.notImplemented();
959     }
960
961     /**
962     * JDBC 3.0
963     *
964     * Retrieves the value of a parameter as an Object in the java programming language.
965     *
966     * @param parameterName - the name of the parameter
967     * @return a java.lang.Object holding the OUT parameter value
968     * @exception SQLException Feature not implemented for now.
969     */

970     public Object JavaDoc getObject(String JavaDoc parameterName)
971     throws SQLException JavaDoc
972     {
973         throw Util.notImplemented();
974     }
975
976     /**
977     * JDBC 3.0
978     *
979     * Returns an object representing the value of OUT parameter i and uses map for
980     * the custom mapping of the parameter value.
981     *
982     * @param parameterName - the name of the parameter
983     * @param map - the mapping from SQL type names to Java classes
984     * @return a java.lang.Object holding the OUT parameter value
985     * @exception SQLException Feature not implemented for now.
986     */

987     public Object JavaDoc getObject(String JavaDoc parameterName, Map JavaDoc map)
988     throws SQLException JavaDoc
989     {
990         checkStatus();
991         if( map == null)
992             throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map",
993                                               "java.sql.CallableStatement.getObject");
994         if(!(map.isEmpty()))
995             throw Util.notImplemented();
996
997         // Map is empty so call the normal getObject method.
998
return getObject(parameterName);
999     }
1000
1001    /**
1002    * JDBC 3.0
1003    *
1004    * Sets the value of the designated parameter with the given object. This method
1005    * is like the method setObject above, except that it assumes a scale of zero.
1006    *
1007    * @param parameterName - the name of the parameter
1008    * @param x - the object containing the input parameter value
1009    * @param targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to
1010    * the database.
1011    * @exception SQLException Feature not implemented for now.
1012    */

1013    public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType)
1014    throws SQLException JavaDoc
1015    {
1016        throw Util.notImplemented();
1017    }
1018
1019    /**
1020    * JDBC 3.0
1021    *
1022    * Sets the value of the designated parameter with the given object. The second
1023    * parameter must be of type Object; therefore, the java.lang equivalent objects
1024    * should be used for built-in types.
1025    *
1026    * @param parameterName - the name of the parameter
1027    * @param x - the object containing the input parameter value
1028    * @exception SQLException Feature not implemented for now.
1029    */

1030    public void setObject(String JavaDoc parameterName, Object JavaDoc x)
1031    throws SQLException JavaDoc
1032    {
1033        throw Util.notImplemented();
1034    }
1035
1036    /*
1037    ** Methods using BigDecimal, moved out of EmbedPreparedStatement
1038    ** to allow that class to support JSR169.
1039    */

1040    /**
1041     * Set a parameter to a java.lang.BigDecimal value.
1042     * The driver converts this to a SQL NUMERIC value when
1043     * it sends it to the database.
1044     *
1045     * @param parameterIndex the first parameter is 1, the second is 2, ...
1046     * @param x the parameter value
1047     * @exception SQLException thrown on failure.
1048     */

1049    public final void setBigDecimal(int parameterIndex, BigDecimal JavaDoc x) throws SQLException JavaDoc {
1050        checkStatus();
1051        try {
1052            /* JDBC is one-based, DBMS is zero-based */
1053            getParms().getParameterForSet(parameterIndex - 1).setBigDecimal(x);
1054
1055        } catch (Throwable JavaDoc t) {
1056            throw EmbedResultSet.noStateChangeException(t);
1057        }
1058    }
1059    /**
1060     * @see CallableStatement#getBigDecimal
1061     * @exception SQLException NoOutputParameters thrown.
1062     */

1063    public final BigDecimal JavaDoc getBigDecimal(int parameterIndex, int scale) throws SQLException JavaDoc
1064    {
1065        BigDecimal JavaDoc v = getBigDecimal(parameterIndex);
1066        if (v != null)
1067            v = v.setScale(scale, BigDecimal.ROUND_HALF_DOWN);
1068        return v;
1069    }
1070    /**
1071        Allow explict setObject conversions by sub-classes for classes
1072        not supported by this variant. In this case handle BigDecimal.
1073        @return true if the object was set successfully, false if no valid
1074        conversion exists.
1075
1076        @exception SQLException value could not be set.
1077    */

1078    boolean setObjectConvert(int parameterIndex, Object JavaDoc x) throws SQLException JavaDoc
1079    {
1080        if (x instanceof BigDecimal JavaDoc) {
1081            setBigDecimal(parameterIndex, (BigDecimal JavaDoc) x);
1082            return true;
1083        }
1084        return false;
1085    }
1086
1087    /////////////////////////////////////////////////////////////////////////
1088
//
1089
// JDBC 4.0 - New public methods
1090
//
1091
/////////////////////////////////////////////////////////////////////////
1092

1093    /**
1094     * Retrieves the value of the designated parameter as a
1095     * <code>java.io.Reader</code> object in the Java programming language.
1096     * Introduced in JDBC 4.0.
1097     *
1098     * @param parameterIndex the first parameter is 1, the second is 2, ...
1099     * @return a <code>java.io.Reader</code> object that contains the parameter
1100     * value; if the value is SQL <code>NULL</code>, the value returned
1101     * is <code>null</code> in the Java programming language.
1102     * @throws SQLException if a database access error occurs or this method is
1103     * called on a closed <code>CallableStatement</code>
1104     */

1105    public Reader JavaDoc getCharacterStream(int parameterIndex)
1106        throws SQLException JavaDoc {
1107        checkStatus();
1108        // Make sure the specified parameter has mode OUT or IN/OUT.
1109
switch (getParms().getParameterMode(parameterIndex)) {
1110            case JDBC30Translation.PARAMETER_MODE_IN:
1111            case JDBC30Translation.PARAMETER_MODE_UNKNOWN:
1112                throw newSQLException(SQLState.LANG_NOT_OUTPUT_PARAMETER,
1113                                      Integer.toString(parameterIndex));
1114        }
1115        Reader JavaDoc reader = null;
1116        int paramType = getParameterJDBCType(parameterIndex);
1117        switch (paramType) {
1118            // Handle character/string types.
1119
case Types.CHAR:
1120            case Types.VARCHAR:
1121            case Types.LONGVARCHAR:
1122            case Types.CLOB:
1123                boolean pushStack = false;
1124                Object JavaDoc syncObject = getConnectionSynchronization();
1125                synchronized (syncObject) {
1126                try {
1127                    DataValueDescriptor param =
1128                        getParms().getParameterForGet(parameterIndex -1);
1129                    if (param.isNull()) {
1130                        break;
1131                    }
1132                    pushStack = true;
1133                    setupContextStack();
1134
1135                    StreamStorable ss = (StreamStorable)param;
1136                    InputStream JavaDoc stream = ss.returnStream();
1137                    if (stream == null) {
1138                        reader = new StringReader JavaDoc(param.getString());
1139                    } else {
1140                        reader = new UTF8Reader(stream, 0, this, syncObject);
1141                    }
1142                } catch (Throwable JavaDoc t) {
1143                    throw EmbedResultSet.noStateChangeException(t);
1144                } finally {
1145                    if (pushStack) {
1146                        restoreContextStack();
1147                    }
1148                }
1149                } // End synchronized block
1150
break;
1151
1152            // Handle binary types.
1153
// JDBC says to support these, but no defintion exists for the output.
1154
// Match JCC which treats the bytes as a UTF-16BE stream.
1155
case Types.BINARY:
1156            case Types.VARBINARY:
1157            case Types.LONGVARBINARY:
1158            case Types.BLOB:
1159                try {
1160                    InputStream JavaDoc is = getBinaryStream(parameterIndex);
1161                    if (is != null) {
1162                        reader = new InputStreamReader JavaDoc(is, "UTF-16BE");
1163                    }
1164                    break;
1165                } catch (UnsupportedEncodingException JavaDoc uee) {
1166                    throw newSQLException(uee.getMessage());
1167                }
1168
1169            default:
1170                throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH,
1171                        "java.io.Reader", Util.typeName(paramType));
1172        }
1173        // Update wasNull.
1174
wasNull = (reader == null);
1175        return reader;
1176    }
1177    
1178    // Private utility classes
1179

1180    /**
1181     * Get binary stream for a parameter.
1182     *
1183     * @param parameterIndex first parameter is 1, second is 2 etc.
1184     * @return a stream for the binary parameter, or <code>null</code>.
1185     *
1186     * @throws SQLException if a database access error occurs.
1187     */

1188    private InputStream JavaDoc getBinaryStream(int parameterIndex)
1189        throws SQLException JavaDoc {
1190        int paramType = getParameterJDBCType(parameterIndex);
1191        switch (paramType) {
1192            case Types.BINARY:
1193            case Types.VARBINARY:
1194            case Types.LONGVARBINARY:
1195            case Types.BLOB:
1196                break;
1197            default:
1198                throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH,
1199                        "java.io.InputStream", Util.typeName(paramType));
1200        }
1201
1202        boolean pushStack = false;
1203        synchronized (getConnectionSynchronization()) {
1204            try {
1205                DataValueDescriptor param =
1206                    getParms().getParameterForGet(parameterIndex -1);
1207                wasNull = param.isNull();
1208                if (wasNull) {
1209                    return null;
1210                }
1211                pushStack = true;
1212                setupContextStack();
1213
1214                StreamStorable ss = (StreamStorable)param;
1215                InputStream JavaDoc stream = ss.returnStream();
1216                if (stream == null) {
1217                    stream = new ByteArrayInputStream JavaDoc(param.getBytes());
1218                } else {
1219                    stream = new BinaryToRawStream(stream, param);
1220                }
1221                return stream;
1222            } catch (Throwable JavaDoc t) {
1223                throw EmbedResultSet.noStateChangeException(t);
1224            } finally {
1225                if (pushStack) {
1226                    restoreContextStack();
1227                }
1228            }
1229        } // End synchronized block
1230
}
1231}
1232
Popular Tags