1 | /* |
2 | |
3 | Derby - Class org.apache.derby.impl.jdbc.EmbedCallableStatement20 |
4 | |
5 | Copyright 1998, 2004 The Apache Software Foundation or its licensors, as applicable. |
6 | |
7 | Licensed under the Apache License, Version 2.0 (the "License"); |
8 | you may not use this file except in compliance with the License. |
9 | You may obtain a copy of the License at |
10 | |
11 | http://www.apache.org/licenses/LICENSE-2.0 |
12 | |
13 | Unless required by applicable law or agreed to in writing, software |
14 | distributed under the License is distributed on an "AS IS" BASIS, |
15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
16 | See the License for the specific language governing permissions and |
17 | limitations under the License. |
18 | |
19 | */ |
20 | |
21 | package org.apache.derby.impl.jdbc; |
22 | |
23 | import java.math.BigDecimal; |
24 | import java.sql.CallableStatement; |
25 | import java.sql.SQLException; |
26 | import java.sql.Date; |
27 | import java.sql.Time; |
28 | import java.sql.Timestamp; |
29 | import java.sql.Types; |
30 | |
31 | /* ---- New jdbc 2.0 types ----- */ |
32 | import java.sql.Array; |
33 | import java.sql.Blob; |
34 | import java.sql.Clob; |
35 | import java.sql.Ref; |
36 | |
37 | import java.net.URL; |
38 | import java.util.Map; |
39 | |
40 | import java.io.ByteArrayInputStream; |
41 | import java.io.InputStream; |
42 | import java.io.InputStreamReader; |
43 | import java.io.Reader; |
44 | import java.io.StringReader; |
45 | import java.io.UnsupportedEncodingException; |
46 | |
47 | import java.util.Calendar; |
48 | |
49 | import org.apache.derby.iapi.error.StandardException; |
50 | |
51 | import org.apache.derby.iapi.services.io.StreamStorable; |
52 | import org.apache.derby.iapi.sql.conn.StatementContext; |
53 | import org.apache.derby.iapi.reference.JDBC30Translation; |
54 | import org.apache.derby.iapi.reference.SQLState; |
55 | import org.apache.derby.iapi.types.DataValueDescriptor; |
56 | |
57 | import org.apache.derby.impl.jdbc.Util; |
58 | import org.apache.derby.impl.jdbc.EmbedConnection; |
59 | import org.apache.derby.impl.jdbc.EmbedResultSet; |
60 | |
61 | |
62 | /** |
63 | * This class extends the EmbedCallableStatement class in order to support new |
64 | * methods and classes that come with JDBC 2.0. |
65 | * |
66 | * @see org.apache.derby.impl.jdbc.EmbedCallableStatement |
67 | * |
68 | * @author francois |
69 | */ |
70 | public class EmbedCallableStatement20 |
71 | extends org.apache.derby.impl.jdbc.EmbedCallableStatement |
72 | { |
73 | |
74 | ////////////////////////////////////////////////////////////// |
75 | // |
76 | // CONSTRUCTORS |
77 | // |
78 | ////////////////////////////////////////////////////////////// |
79 | public EmbedCallableStatement20 (EmbedConnection conn, String sql, |
80 | int resultSetType, |
81 | int resultSetConcurrency, |
82 | int resultSetHoldability) |
83 | throws SQLException |
84 | { |
85 | super(conn, sql, resultSetType, resultSetConcurrency, resultSetHoldability); |
86 | } |
87 | |
88 | ///////////////////////////////////////////////////////////////////////// |
89 | // |
90 | // JDBC 2.0 - New public methods |
91 | // |
92 | ///////////////////////////////////////////////////////////////////////// |
93 | |
94 | /** |
95 | * JDBC 2.0 |
96 | * |
97 | * Get the value of a NUMERIC parameter as a java.math.BigDecimal object. |
98 | * |
99 | * @param parameterIndex the first parameter is 1, the second is 2, ... |
100 | * @return the parameter value (full precision); if the value is SQL NULL, |
101 | * the result is null |
102 | * @exception SQLException if a database-access error occurs. |
103 | */ |
104 | public BigDecimal getBigDecimal(int parameterIndex) throws SQLException |
105 | { |
106 | checkStatus(); |
107 | try { |
108 | DataValueDescriptor dvd = getParms().getParameterForGet(parameterIndex-1); |
109 | if (wasNull = dvd.isNull()) |
110 | return null; |
111 | |
112 | return org.apache.derby.iapi.types.SQLDecimal.getBigDecimal(dvd); |
113 | |
114 | } catch (StandardException e) |
115 | { |
116 | throw EmbedResultSet.noStateChangeException(e); |
117 | } |
118 | } |
119 | |
120 | |
121 | /** |
122 | * JDBC 2.0 |
123 | * |
124 | * Returns an object representing the value of OUT parameter @i. |
125 | * Use the @map to determine the class from which to construct |
126 | * data of SQL structured and distinct types. |
127 | * |
128 | * @param i the first parameter is 1, the second is 2, ... |
129 | * @param map the mapping from SQL type names to Java classes |
130 | * @return a java.lang.Object holding the OUT parameter value. |
131 | * @exception SQLException if a database-access error occurs. |
132 | */ |
133 | public Object getObject (int i, java.util.Map map) throws SQLException |
134 | { |
135 | checkStatus(); |
136 | if( map == null) |
137 | throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map", |
138 | "java.sql.CallableStatement.getObject"); |
139 | if(!(map.isEmpty())) |
140 | throw Util.notImplemented(); |
141 | // Map is empty call the normal getObject method. |
142 | return getObject(i); |
143 | } |
144 | |
145 | /** |
146 | * JDBC 2.0 |
147 | * |
148 | * Get a REF(<structured-type>) OUT parameter. |
149 | * |
150 | * @param i the first parameter is 1, the second is 2, ... |
151 | * @return an object representing data of an SQL REF Type |
152 | * @exception SQLException if a database-access error occurs. |
153 | */ |
154 | public Ref getRef (int i) throws SQLException { |
155 | throw Util.notImplemented(); |
156 | } |
157 | |
158 | /** |
159 | * JDBC 2.0 |
160 | * |
161 | * Get an Array OUT parameter. |
162 | * |
163 | * @param i the first parameter is 1, the second is 2, ... |
164 | * @return an object representing an SQL array |
165 | * @exception SQLException if a database-access error occurs. |
166 | */ |
167 | public Array getArray (int i) throws SQLException { |
168 | throw Util.notImplemented(); |
169 | } |
170 | |
171 | |
172 | |
173 | /* |
174 | * Note: all the JDBC 2.0 Prepared statement methods are duplicated in here |
175 | * because this class inherits from Local/EmbedCallableStatement, which |
176 | * inherits from local/PreparedStatement. This class should inherit from a |
177 | * local20/PreparedStatement. Since java does not allow multiple inheritance, |
178 | * duplicate the code here. |
179 | */ |
180 | |
181 | /** |
182 | * JDBC 2.0 |
183 | * |
184 | * Set a REF(<structured-type>) parameter. |
185 | * |
186 | * @param i the first parameter is 1, the second is 2, ... |
187 | * @param x an object representing data of an SQL REF Type |
188 | * @exception SQLException Feature not implemented for now. |
189 | */ |
190 | public void setRef (int i, Ref x) throws SQLException { |
191 | throw Util.notImplemented(); |
192 | } |
193 | |
194 | /** |
195 | * JDBC 2.0 |
196 | * |
197 | * Set an Array parameter. |
198 | * |
199 | * @param i the first parameter is 1, the second is 2, ... |
200 | * @param x an object representing an SQL array |
201 | * @exception SQLException Feature not implemented for now. |
202 | */ |
203 | public void setArray (int i, Array x) throws SQLException { |
204 | throw Util.notImplemented(); |
205 | } |
206 | |
207 | |
208 | ///////////////////////////////////////////////////////////////////////// |
209 | // |
210 | // JDBC 3.0 - New public methods |
211 | // |
212 | ///////////////////////////////////////////////////////////////////////// |
213 | |
214 | /** |
215 | * JDBC 3.0 |
216 | * |
217 | * Registers the OUT parameter named parameterName to the JDBC type sqlType. |
218 | * All OUT parameters must be registered before a stored procedure is executed. |
219 | * |
220 | * @param parameterName - the name of the parameter |
221 | * @param sqlType - the JDBC type code defined by java.sql.Types. If the |
222 | * parameter is of JDBC type NUMERIC or DECIMAL, the version of registerOutParameter |
223 | * that accepts a scale value should be used. |
224 | * @exception SQLException Feature not implemented for now. |
225 | */ |
226 | public void registerOutParameter(String parameterName, |
227 | int sqlType) |
228 | throws SQLException |
229 | { |
230 | throw Util.notImplemented(); |
231 | } |
232 | |
233 | /** |
234 | * JDBC 3.0 |
235 | * |
236 | * Registers the designated output parameter. This version of the method |
237 | * registerOutParameter should be used for a user-named or REF output parameter. |
238 | * |
239 | * @param parameterName - the name of the parameter |
240 | * @param sqlType - the SQL type code defined by java.sql.Types. |
241 | * @param typeName - the fully-qualified name of an SQL structure type |
242 | * @exception SQLException Feature not implemented for now. |
243 | */ |
244 | public void registerOutParameter(String parameterName, |
245 | int sqlType, String typeName) |
246 | throws SQLException |
247 | { |
248 | throw Util.notImplemented(); |
249 | } |
250 | |
251 | /** |
252 | * JDBC 3.0 |
253 | * |
254 | * Registers the parameter named parameterName to the JDBC type sqlType. |
255 | * This method must be called before a stored procedure is executed. |
256 | * |
257 | * @param parameterName - the name of the parameter |
258 | * @param sqlType - the SQL type code defined by java.sql.Types. |
259 | * @param scale - the desired number of digits to the right of the decimal point. |
260 | * It must be greater than or equal to zero. |
261 | * @exception SQLException Feature not implemented for now. |
262 | */ |
263 | public void registerOutParameter(String parameterName, |
264 | int sqlType, int scale) |
265 | throws SQLException |
266 | { |
267 | throw Util.notImplemented(); |
268 | } |
269 | |
270 | /** |
271 | * JDBC 3.0 |
272 | * |
273 | * Retrieves the value of a JDBC REF (<structured-type) parameter as a Ref object |
274 | * in the Java programming language. |
275 | * |
276 | * @param parameterName - the name of the parameter |
277 | * @return the parameter value as a Ref object in the Java Programming language. |
278 | * If the value is SQL NULL, the result is null. |
279 | * @exception SQLException Feature not implemented for now. |
280 | */ |
281 | public Ref getRef(String parameterName) |
282 | throws SQLException |
283 | { |
284 | throw Util.notImplemented(); |
285 | } |
286 | |
287 | /** |
288 | * JDBC 3.0 |
289 | * |
290 | * Retrieves the value of a JDBC BLOB parameter as a Blob object |
291 | * in the Java programming language. |
292 | * |
293 | * @param parameterName - the name of the parameter |
294 | * @return the parameter value as a Blob object in the Java Programming language. |
295 | * If the value is SQL NULL, the result is null. |
296 | * @exception SQLException Feature not implemented for now. |
297 | */ |
298 | public Blob getBlob(String parameterName) |
299 | throws SQLException |
300 | { |
301 | throw Util.notImplemented(); |
302 | } |
303 | |
304 | /** |
305 | * JDBC 3.0 |
306 | * |
307 | * Retrieves the value of a JDBC CLOB parameter as a Clob object |
308 | * in the Java programming language. |
309 | * |
310 | * @param parameterName - the name of the parameter |
311 | * @return the parameter value as a Clob object in the Java Programming language. |
312 | * If the value is SQL NULL, the result is null. |
313 | * @exception SQLException Feature not implemented for now. |
314 | */ |
315 | public Clob getClob(String parameterName) |
316 | throws SQLException |
317 | { |
318 | throw Util.notImplemented(); |
319 | } |
320 | |
321 | /** |
322 | * JDBC 3.0 |
323 | * |
324 | * Retrieves the value of a JDBC ARRAY parameter as an Array object |
325 | * in the Java programming language. |
326 | * |
327 | * @param parameterName - the name of the parameter |
328 | * @return the parameter value as a Array object in the Java Programming language. |
329 | * If the value is SQL NULL, the result is null. |
330 | * @exception SQLException Feature not implemented for now. |
331 | */ |
332 | public Array getArray(String parameterName) |
333 | throws SQLException |
334 | { |
335 | throw Util.notImplemented(); |
336 | } |
337 | |
338 | /** |
339 | * JDBC 3.0 |
340 | * |
341 | * Sets the designated parameter to SQL NULL. |
342 | * |
343 | * @param parameterName - the name of the parameter |
344 | * @param sqlType - the SQL type code defined in java.sql.Types |
345 | * @exception SQLException Feature not implemented for now. |
346 | */ |
347 | public void setNull(String parameterName, int sqlType) |
348 | throws SQLException |
349 | { |
350 | throw Util.notImplemented(); |
351 | } |
352 | /** |
353 | * JDBC 3.0 |
354 | * |
355 | * Sets the designated parameter to SQL NULL. |
356 | * |
357 | * @param parameterName - the name of the parameter |
358 | * @param sqlType - the SQL type code defined in java.sql.Types |
359 | * @param typeName - the fully-qualified name of an SQL user-defined type |
360 | * @exception SQLException Feature not implemented for now. |
361 | */ |
362 | public void setNull(String parameterName, int sqlType, String typeName) |
363 | throws SQLException |
364 | { |
365 | throw Util.notImplemented(); |
366 | } |
367 | |
368 | /** |
369 | * JDBC 3.0 |
370 | * |
371 | * Sets the designated parameter to the given Java boolean value. The driver |
372 | * converts this to an SQL BIT value when it sends it to the database. |
373 | * |
374 | * @param parameterName - the name of the parameter |
375 | * @param x - the parameter value |
376 | * @exception SQLException Feature not implemented for now. |
377 | */ |
378 | public void setBoolean(String parameterName, boolean x) |
379 | throws SQLException |
380 | { |
381 | throw Util.notImplemented(); |
382 | } |
383 | |
384 | /** |
385 | * JDBC 3.0 |
386 | * |
387 | * Retrieves the value of a JDBC BIT parameter as a boolean in the Java |
388 | * programming language. |
389 | * |
390 | * @param parameterName - the name of the parameter |
391 | * @return the parameter value. If the value is SQL NULL, the result is false. |
392 | * @exception SQLException Feature not implemented for now. |
393 | */ |
394 | public boolean getBoolean(String parameterName) |
395 | throws SQLException |
396 | { |
397 | throw Util.notImplemented(); |
398 | } |
399 | |
400 | /** |
401 | * JDBC 3.0 |
402 | * |
403 | * Sets the designated parameter to the given Java byte value. The driver |
404 | * converts this to an SQL TINYINT value when it sends it to the database. |
405 | * |
406 | * @param parameterName - the name of the parameter |
407 | * @param x - the parameter value |
408 | * @exception SQLException Feature not implemented for now. |
409 | */ |
410 | public void setByte(String parameterName, byte x) |
411 | throws SQLException |
412 | { |
413 | throw Util.notImplemented(); |
414 | } |
415 | |
416 | /** |
417 | * JDBC 3.0 |
418 | * |
419 | * Retrieves the value of a JDBC TINYINT parameter as a byte in the Java |
420 | * programming language. |
421 | * |
422 | * @param parameterName - the name of the parameter |
423 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
424 | * @exception SQLException Feature not implemented for now. |
425 | */ |
426 | public byte getByte(String parameterName) |
427 | throws SQLException |
428 | { |
429 | throw Util.notImplemented(); |
430 | } |
431 | |
432 | /** |
433 | * JDBC 3.0 |
434 | * |
435 | * Sets the designated parameter to the given Java short value. The driver |
436 | * converts this to an SQL SMALLINT value when it sends it to the database. |
437 | * |
438 | * @param parameterName - the name of the parameter |
439 | * @param x - the parameter value |
440 | * @exception SQLException Feature not implemented for now. |
441 | */ |
442 | public void setShort(String parameterName, short x) |
443 | throws SQLException |
444 | { |
445 | throw Util.notImplemented(); |
446 | } |
447 | |
448 | /** |
449 | * JDBC 3.0 |
450 | * |
451 | * Retrieves the value of a JDBC SMALLINT parameter as a short in the Java |
452 | * programming language. |
453 | * |
454 | * @param parameterName - the name of the parameter |
455 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
456 | * @exception SQLException Feature not implemented for now. |
457 | */ |
458 | public short getShort(String parameterName) |
459 | throws SQLException |
460 | { |
461 | throw Util.notImplemented(); |
462 | } |
463 | |
464 | /** |
465 | * JDBC 3.0 |
466 | * |
467 | * Sets the designated parameter to the given Java int value. The driver |
468 | * converts this to an SQL INTEGER value when it sends it to the database. |
469 | * |
470 | * @param parameterName - the name of the parameter |
471 | * @param x - the parameter value |
472 | * @exception SQLException Feature not implemented for now. |
473 | */ |
474 | public void setInt(String parameterName, int x) |
475 | throws SQLException |
476 | { |
477 | throw Util.notImplemented(); |
478 | } |
479 | |
480 | /** |
481 | * JDBC 3.0 |
482 | * |
483 | * Retrieves the value of a JDBC INTEGER parameter as a int in the Java |
484 | * programming language. |
485 | * |
486 | * @param parameterName - the name of the parameter |
487 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
488 | * @exception SQLException Feature not implemented for now. |
489 | */ |
490 | public int getInt(String parameterName) |
491 | throws SQLException |
492 | { |
493 | throw Util.notImplemented(); |
494 | } |
495 | |
496 | /** |
497 | * JDBC 3.0 |
498 | * |
499 | * Sets the designated parameter to the given Java long value. The driver |
500 | * converts this to an SQL BIGINT value when it sends it to the database. |
501 | * |
502 | * @param parameterName - the name of the parameter |
503 | * @param x - the parameter value |
504 | * @exception SQLException Feature not implemented for now. |
505 | */ |
506 | public void setLong(String parameterName, long x) |
507 | throws SQLException |
508 | { |
509 | throw Util.notImplemented(); |
510 | } |
511 | |
512 | /** |
513 | * JDBC 3.0 |
514 | * |
515 | * Retrieves the value of a JDBC BIGINT parameter as a long in the Java |
516 | * programming language. |
517 | * |
518 | * @param parameterName - the name of the parameter |
519 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
520 | * @exception SQLException Feature not implemented for now. |
521 | */ |
522 | public long getLong(String parameterName) |
523 | throws SQLException |
524 | { |
525 | throw Util.notImplemented(); |
526 | } |
527 | |
528 | /** |
529 | * JDBC 3.0 |
530 | * |
531 | * Sets the designated parameter to the given Java float value. The driver |
532 | * converts this to an SQL FLOAT value when it sends it to the database. |
533 | * |
534 | * @param parameterName - the name of the parameter |
535 | * @param x - the parameter value |
536 | * @exception SQLException Feature not implemented for now. |
537 | */ |
538 | public void setFloat(String parameterName, float x) |
539 | throws SQLException |
540 | { |
541 | throw Util.notImplemented(); |
542 | } |
543 | |
544 | /** |
545 | * JDBC 3.0 |
546 | * |
547 | * Retrieves the value of a JDBC FLOAT parameter as a float in the Java |
548 | * programming language. |
549 | * |
550 | * @param parameterName - the name of the parameter |
551 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
552 | * @exception SQLException Feature not implemented for now. |
553 | */ |
554 | public float getFloat(String parameterName) |
555 | throws SQLException |
556 | { |
557 | throw Util.notImplemented(); |
558 | } |
559 | |
560 | /** |
561 | * JDBC 3.0 |
562 | * |
563 | * Sets the designated parameter to the given Java double value. The driver |
564 | * converts this to an SQL DOUBLE value when it sends it to the database. |
565 | * |
566 | * @param parameterName - the name of the parameter |
567 | * @param x - the parameter value |
568 | * @exception SQLException Feature not implemented for now. |
569 | */ |
570 | public void setDouble(String parameterName, double x) |
571 | throws SQLException |
572 | { |
573 | throw Util.notImplemented(); |
574 | } |
575 | |
576 | /** |
577 | * JDBC 3.0 |
578 | * |
579 | * Retrieves the value of a JDBC DOUBLE parameter as a double in the Java |
580 | * programming language. |
581 | * |
582 | * @param parameterName - the name of the parameter |
583 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
584 | * @exception SQLException Feature not implemented for now. |
585 | */ |
586 | public double getDouble(String parameterName) |
587 | throws SQLException |
588 | { |
589 | throw Util.notImplemented(); |
590 | } |
591 | |
592 | /** |
593 | * JDBC 3.0 |
594 | * |
595 | * Sets the designated parameter to the given java.math.BigDecimal value. The driver |
596 | * converts this to an SQL NUMERIC value when it sends it to the database. |
597 | * |
598 | * @param parameterName - the name of the parameter |
599 | * @param x - the parameter value |
600 | * @exception SQLException Feature not implemented for now. |
601 | */ |
602 | public void setBigDecimal(String parameterName, BigDecimal x) |
603 | throws SQLException |
604 | { |
605 | throw Util.notImplemented(); |
606 | } |
607 | |
608 | /** |
609 | * JDBC 3.0 |
610 | * |
611 | * Retrieves the value of a JDBC NUMERIC parameter as a java.math.BigDecimal |
612 | * object with as many digits to the right of the decimal point as the value contains |
613 | * |
614 | * @param parameterName - the name of the parameter |
615 | * @return the parameter value. If the value is SQL NULL, the result is 0. |
616 | * @exception SQLException Feature not implemented for now. |
617 | */ |
618 | public BigDecimal getBigDecimal(String parameterName) |
619 | throws SQLException |
620 | { |
621 | throw Util.notImplemented(); |
622 | } |
623 | |
624 | /** |
625 | * JDBC 3.0 |
626 | * |
627 | * Sets the designated parameter to the given Java String value. The driver |
628 | * converts this to an SQL VARCHAR OR LONGVARCHAR value (depending on the |
629 | * argument's size relative the driver's limits on VARCHAR values) when it |
630 | * sends it to the database. |
631 | * |
632 | * @param parameterName - the name of the parameter |
633 | * @param x - the parameter value |
634 | * @exception SQLException Feature not implemented for now. |
635 | */ |
636 | public void setString(String parameterName, String x) |
637 | throws SQLException |
638 | { |
639 | throw Util.notImplemented(); |
640 | } |
641 | |
642 | /** |
643 | * JDBC 3.0 |
644 | * |
645 | * Retrieves the value of a JDBC CHAR, VARCHAR, or LONGVARCHAR parameter as |
646 | * a String in the Java programming language. |
647 | * |
648 | * @param parameterName - the name of the parameter |
649 | * @return the parameter value. If the value is SQL NULL, the result is null. |
650 | * @exception SQLException Feature not implemented for now. |
651 | */ |
652 | public String getString(String parameterName) |
653 | throws SQLException |
654 | { |
655 | throw Util.notImplemented(); |
656 | } |
657 | |
658 | /** |
659 | * JDBC 3.0 |
660 | * |
661 | * Sets the designated parameter to the given Java array of bytes. The driver |
662 | * converts this to an SQL VARBINARY OR LONGVARBINARY (depending on the argument's |
663 | * size relative to the driver's limits on VARBINARY values)when it sends it to |
664 | * the database. |
665 | * |
666 | * @param parameterName - the name of the parameter |
667 | * @param x - the parameter value |
668 | * @exception SQLException Feature not implemented for now. |
669 | */ |
670 | public void setBytes(String parameterName, byte[] x) |
671 | throws SQLException |
672 | { |
673 | throw Util.notImplemented(); |
674 | } |
675 | |
676 | /** |
677 | * JDBC 3.0 |
678 | * |
679 | * Retrieves the value of a JDBC BINARY or VARBINARY parameter as an array |
680 | * of byte values in the Java programming language. |
681 | * |
682 | * @param parameterName - the name of the parameter |
683 | * @return the parameter value. If the value is SQL NULL, the result is null. |
684 | * @exception SQLException Feature not implemented for now. |
685 | */ |
686 | public byte[] getBytes(String parameterName) |
687 | throws SQLException |
688 | { |
689 | throw Util.notImplemented(); |
690 | } |
691 | |
692 | /** |
693 | * JDBC 3.0 |
694 | * |
695 | * Sets the designated parameter to the given java.sql.Date value. The driver |
696 | * converts this to an SQL DATE value when it sends it to the database. |
697 | * |
698 | * @param parameterName - the name of the parameter |
699 | * @param x - the parameter value |
700 | * @exception SQLException Feature not implemented for now. |
701 | */ |
702 | public void setDate(String parameterName, Date x) |
703 | throws SQLException |
704 | { |
705 | throw Util.notImplemented(); |
706 | } |
707 | |
708 | /** |
709 | * JDBC 3.0 |
710 | * |
711 | * Sets the designated parameter to the given java.sql.Date value, using the given |
712 | * Calendar object. |
713 | * |
714 | * @param parameterName - the name of the parameter |
715 | * @param x - the parameter value |
716 | * @param cal - the Calendar object the driver will use to construct the date |
717 | * @exception SQLException Feature not implemented for now. |
718 | */ |
719 | public void setDate(String parameterName, Date x, Calendar cal) |
720 | throws SQLException |
721 | { |
722 | throw Util.notImplemented(); |
723 | } |
724 | |
725 | /** |
726 | * JDBC 3.0 |
727 | * |
728 | * Retrieves the value of a JDBC DATE parameter as ajava.sql.Date object |
729 | * |
730 | * @param parameterName - the name of the parameter |
731 | * @return the parameter value. If the value is SQL NULL, the result is null. |
732 | * @exception SQLException Feature not implemented for now. |
733 | */ |
734 | public Date getDate(String parameterName) |
735 | throws SQLException |
736 | { |
737 | throw Util.notImplemented(); |
738 | } |
739 | |
740 | /** |
741 | * JDBC 3.0 |
742 | * |
743 | * Retrieves the value of a JDBC DATE parameter as a java.sql.Date object, |
744 | * using the given Calendar object to construct the date object. |
745 | * |
746 | * @param parameterName - the name of the parameter |
747 | * @param cal - the Calendar object the driver will use to construct the date |
748 | * @return the parameter value. If the value is SQL NULL, the result is null. |
749 | * @exception SQLException Feature not implemented for now. |
750 | */ |
751 | public Date getDate(String parameterName, Calendar cal) |
752 | throws SQLException |
753 | { |
754 | throw Util.notImplemented(); |
755 | } |
756 | |
757 | /** |
758 | * JDBC 3.0 |
759 | * |
760 | * Sets the designated parameter to the given java.sql.Time value. The driver |
761 | * converts this to an SQL TIME value when it sends it to the database. |
762 | * |
763 | * @param parameterName - the name of the parameter |
764 | * @param x - the parameter value |
765 | * @exception SQLException Feature not implemented for now. |
766 | */ |
767 | public void setTime(String parameterName, Time x) |
768 | throws SQLException |
769 | { |
770 | throw Util.notImplemented(); |
771 | } |
772 | |
773 | /** |
774 | * JDBC 3.0 |
775 | * |
776 | * Retrieves the value of a JDBC TIME parameter as ajava.sql.Time object |
777 | * |
778 | * @param parameterName - the name of the parameter |
779 | * @return the parameter value. If the value is SQL NULL, the result is null. |
780 | * @exception SQLException Feature not implemented for now. |
781 | */ |
782 | public Time getTime(String parameterName) |
783 | throws SQLException |
784 | { |
785 | throw Util.notImplemented(); |
786 | } |
787 | |
788 | /** |
789 | * JDBC 3.0 |
790 | * |
791 | * Retrieves the value of a JDBC TIME parameter as a java.sql.Time object, |
792 | * using the given Calendar object to construct the time object. |
793 | * |
794 | * @param parameterName - the name of the parameter |
795 | * @param cal - the Calendar object the driver will use to construct the time |
796 | * @return the parameter value. If the value is SQL NULL, the result is null. |
797 | * @exception SQLException Feature not implemented for now. |
798 | */ |
799 | public Time getTime(String parameterName, Calendar cal) |
800 | throws SQLException |
801 | { |
802 | throw Util.notImplemented(); |
803 | } |
804 | |
805 | /** |
806 | * JDBC 3.0 |
807 | * |
808 | * Sets the designated parameter to the given java.sql.Time value using the |
809 | * Calendar object |
810 | * |
811 | * @param parameterName - the name of the parameter |
812 | * @param x - the parameter value |
813 | * @param cal - the Calendar object the driver will use to construct the time |
814 | * @exception SQLException Feature not implemented for now. |
815 | */ |
816 | public void setTime(String parameterName, Time x, Calendar cal) |
817 | throws SQLException |
818 | { |
819 | throw Util.notImplemented(); |
820 | } |
821 | |
822 | /** |
823 | * JDBC 3.0 |
824 | * |
825 | * Sets the designated parameter to the given java.sql.Timestamp value. The driver |
826 | * converts this to an SQL TIMESTAMP value when it sends it to the database. |
827 | * |
828 | * @param parameterName - the name of the parameter |
829 | * @param x - the parameter value |
830 | * @exception SQLException Feature not implemented for now. |
831 | */ |
832 | public void setTimestamp(String parameterName, Timestamp x) |
833 | throws SQLException |
834 | { |
835 | throw Util.notImplemented(); |
836 | } |
837 | |
838 | /** |
839 | * JDBC 3.0 |
840 | * |
841 | * Sets the designated parameter to the given java.sql.Timestamp value, using the |
842 | * given Calendar object |
843 | * |
844 | * @param parameterName - the name of the parameter |
845 | * @param x - the parameter value |
846 | * @param cal - the Calendar object the driver will use to construct the timestamp. |
847 | * @exception SQLException Feature not implemented for now. |
848 | */ |
849 | public void setTimestamp(String parameterName, Timestamp x, Calendar cal) |
850 | throws SQLException |
851 | { |
852 | throw Util.notImplemented(); |
853 | } |
854 | |
855 | /** |
856 | * JDBC 3.0 |
857 | * |
858 | * Retrieves the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp object |
859 | * |
860 | * @param parameterName - the name of the parameter |
861 | * @return the parameter value. If the value is SQL NULL, the result is null. |
862 | * @exception SQLException Feature not implemented for now. |
863 | */ |
864 | public Timestamp getTimestamp(String parameterName) |
865 | throws SQLException |
866 | { |
867 | throw Util.notImplemented(); |
868 | } |
869 | |
870 | /** |
871 | * JDBC 3.0 |
872 | * |
873 | * Retrieves the value of a JDBC TIMESTAMP parameter as a java.sql.Timestamp object, |
874 | * using the given Calendar object to construct the Timestamp object. |
875 | * |
876 | * @param parameterName - the name of the parameter |
877 | * @param cal - the Calendar object the driver will use to construct the Timestamp |
878 | * @return the parameter value. If the value is SQL NULL, the result is null. |
879 | * @exception SQLException Feature not implemented for now. |
880 | */ |
881 | public Timestamp getTimestamp(String parameterName, Calendar cal) |
882 | throws SQLException |
883 | { |
884 | throw Util.notImplemented(); |
885 | } |
886 | |
887 | /** |
888 | * JDBC 3.0 |
889 | * |
890 | * Sets the designated parameter to the given input stream, which will have the |
891 | * specified number of bytes. |
892 | * |
893 | * @param parameterName - the name of the parameter |
894 | * @param x - the Java input stream that contains the ASCII parameter value |
895 | * @param length - the number of bytes in the stream |
896 | * @exception SQLException Feature not implemented for now. |
897 | */ |
898 | public void setAsciiStream(String parameterName, InputStream x, int length) |
899 | throws SQLException |
900 | { |
901 | throw Util.notImplemented(); |
902 | } |
903 | |
904 | /** |
905 | * JDBC 3.0 |
906 | * |
907 | * Sets the designated parameter to the given input stream, which will have the |
908 | * specified number of bytes. |
909 | * |
910 | * @param parameterName - the name of the parameter |
911 | * @param x - the Java input stream that contains the binary parameter value |
912 | * @param length - the number of bytes in the stream |
913 | * @exception SQLException Feature not implemented for now. |
914 | */ |
915 | public void setBinaryStream(String parameterName, InputStream x, int length) |
916 | throws SQLException |
917 | { |
918 | throw Util.notImplemented(); |
919 | } |
920 | |
921 | /** |
922 | * JDBC 3.0 |
923 | * |
924 | * Sets the designated parameter to the given Reader object, which is the given |
925 | * number of characters long. |
926 | * |
927 | * @param parameterName - the name of the parameter |
928 | * @param reader - the java.io.Reader object that contains the UNICODE data |
929 | * @param length - the number of characters in the stream |
930 | * @exception SQLException Feature not implemented for now. |
931 | */ |
932 | public void setCharacterStream(String parameterName, Reader reader, int length) |
933 | throws SQLException |
934 | { |
935 | throw Util.notImplemented(); |
936 | } |
937 | |
938 | /** |
939 | * JDBC 3.0 |
940 | * |
941 | * Sets the value of the designated parameter with the given object. The second |
942 | * argument must be an object type; for integral values, the java.lang equivalent |
943 | * objects should be used. |
944 | * |
945 | * @param parameterName - the name of the parameter |
946 | * @param x - the object containing the input parameter value |
947 | * @param targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to |
948 | * the database. The scale argument may further qualify this type. |
949 | * @param scale - for java.sql.Types.DECIMAL or java.sql.Types.NUMERIC types, this |
950 | * is the number of digits after the decimal point. For all other types, this value |
951 | * will be ignored. |
952 | * @exception SQLException Feature not implemented for now. |
953 | */ |
954 | public void setObject(String parameterName, Object x, int targetSqlType, int scale) |
955 | throws SQLException |
956 | { |
957 | throw Util.notImplemented(); |
958 | } |
959 | |
960 | /** |
961 | * JDBC 3.0 |
962 | * |
963 | * Retrieves the value of a parameter as an Object in the java programming language. |
964 | * |
965 | * @param parameterName - the name of the parameter |
966 | * @return a java.lang.Object holding the OUT parameter value |
967 | * @exception SQLException Feature not implemented for now. |
968 | */ |
969 | public Object getObject(String parameterName) |
970 | throws SQLException |
971 | { |
972 | throw Util.notImplemented(); |
973 | } |
974 | |
975 | /** |
976 | * JDBC 3.0 |
977 | * |
978 | * Returns an object representing the value of OUT parameter i and uses map for |
979 | * the custom mapping of the parameter value. |
980 | * |
981 | * @param parameterName - the name of the parameter |
982 | * @param map - the mapping from SQL type names to Java classes |
983 | * @return a java.lang.Object holding the OUT parameter value |
984 | * @exception SQLException Feature not implemented for now. |
985 | */ |
986 | public Object getObject(String parameterName, Map map) |
987 | throws SQLException |
988 | { |
989 | checkStatus(); |
990 | if( map == null) |
991 | throw Util.generateCsSQLException(SQLState.INVALID_API_PARAMETER,map,"map", |
992 | "java.sql.CallableStatement.getObject"); |
993 | if(!(map.isEmpty())) |
994 | throw Util.notImplemented(); |
995 | |
996 | // Map is empty so call the normal getObject method. |
997 | return getObject(parameterName); |
998 | } |
999 | |
1000 | /** |
1001 | * JDBC 3.0 |
1002 | * |
1003 | * Sets the value of the designated parameter with the given object. This method |
1004 | * is like the method setObject above, except that it assumes a scale of zero. |
1005 | * |
1006 | * @param parameterName - the name of the parameter |
1007 | * @param x - the object containing the input parameter value |
1008 | * @param targetSqlType - the SQL type (as defined in java.sql.Types) to be sent to |
1009 | * the database. |
1010 | * @exception SQLException Feature not implemented for now. |
1011 | */ |
1012 | public void setObject(String parameterName, Object x, int targetSqlType) |
1013 | throws SQLException |
1014 | { |
1015 | throw Util.notImplemented(); |
1016 | } |
1017 | |
1018 | /** |
1019 | * JDBC 3.0 |
1020 | * |
1021 | * Sets the value of the designated parameter with the given object. The second |
1022 | * parameter must be of type Object; therefore, the java.lang equivalent objects |
1023 | * should be used for built-in types. |
1024 | * |
1025 | * @param parameterName - the name of the parameter |
1026 | * @param x - the object containing the input parameter value |
1027 | * @exception SQLException Feature not implemented for now. |
1028 | */ |
1029 | public void setObject(String parameterName, Object x) |
1030 | throws SQLException |
1031 | { |
1032 | throw Util.notImplemented(); |
1033 | } |
1034 | |
1035 | /* |
1036 | ** Methods using BigDecimal, moved out of EmbedPreparedStatement |
1037 | ** to allow that class to support JSR169. |
1038 | */ |
1039 | /** |
1040 | * Set a parameter to a java.lang.BigDecimal value. |
1041 | * The driver converts this to a SQL NUMERIC value when |
1042 | * it sends it to the database. |
1043 | * |
1044 | * @param parameterIndex the first parameter is 1, the second is 2, ... |
1045 | * @param x the parameter value |
1046 | * @exception SQLException thrown on failure. |
1047 | */ |
1048 | public final void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { |
1049 | checkStatus(); |
1050 | try { |
1051 | /* JDBC is one-based, DBMS is zero-based */ |
1052 | getParms().getParameterForSet(parameterIndex - 1).setBigDecimal(x); |
1053 | |
1054 | } catch (Throwable t) { |
1055 | throw EmbedResultSet.noStateChangeException(t); |
1056 | } |
1057 | } |
1058 | /** |
1059 | * @see CallableStatement#getBigDecimal |
1060 | * @exception SQLException NoOutputParameters thrown. |
1061 | */ |
1062 | public final BigDecimal getBigDecimal(int parameterIndex, int scale) throws SQLException |
1063 | { |
1064 | BigDecimal v = getBigDecimal(parameterIndex); |
1065 | if (v != null) |
1066 | v = v.setScale(scale, BigDecimal.ROUND_HALF_DOWN); |
1067 | return v; |
1068 | } |
1069 | /** |
1070 | Allow explict setObject conversions by sub-classes for classes |
1071 | not supported by this variant. In this case handle BigDecimal. |
1072 | @return true if the object was set successfully, false if no valid |
1073 | conversion exists. |
1074 | |
1075 | @exception SQLException value could not be set. |
1076 | */ |
1077 | boolean setObjectConvert(int parameterIndex, Object x) throws SQLException |
1078 | { |
1079 | if (x instanceof BigDecimal) { |
1080 | setBigDecimal(parameterIndex, (BigDecimal) x); |
1081 | return true; |
1082 | } |
1083 | return false; |
1084 | } |
1085 | |
1086 | ///////////////////////////////////////////////////////////////////////// |
1087 | // |
1088 | // JDBC 4.0 - New public methods |
1089 | // |
1090 | ///////////////////////////////////////////////////////////////////////// |
1091 | |
1092 | /** |
1093 | * Retrieves the value of the designated parameter as a |
1094 | * <code>java.io.Reader</code> object in the Java programming language. |
1095 | * Introduced in JDBC 4.0. |
1096 | * |
1097 | * @param parameterIndex the first parameter is 1, the second is 2, ... |
1098 | * @return a <code>java.io.Reader</code> object that contains the parameter |
1099 | * value; if the value is SQL <code>NULL</code>, the value returned |
1100 | * is <code>null</code> in the Java programming language. |
1101 | * @throws SQLException if a database access error occurs or this method is |
1102 | * called on a closed <code>CallableStatement</code> |
1103 | */ |
1104 | public Reader getCharacterStream(int parameterIndex) |
1105 | throws SQLException { |
1106 | checkStatus(); |
1107 | // Make sure the specified parameter has mode OUT or IN/OUT. |
1108 | switch (getParms().getParameterMode(parameterIndex)) { |
1109 | case JDBC30Translation.PARAMETER_MODE_IN: |
1110 | case JDBC30Translation.PARAMETER_MODE_UNKNOWN: |
1111 | throw newSQLException(SQLState.LANG_NOT_OUTPUT_PARAMETER, |
1112 | Integer.toString(parameterIndex)); |
1113 | } |
1114 | Reader reader = null; |
1115 | int paramType = getParameterJDBCType(parameterIndex); |
1116 | switch (paramType) { |
1117 | // Handle character/string types. |
1118 | case Types.CHAR: |
1119 | case Types.VARCHAR: |
1120 | case Types.LONGVARCHAR: |
1121 | case Types.CLOB: |
1122 | boolean pushStack = false; |
1123 | Object syncObject = getConnectionSynchronization(); |
1124 | synchronized (syncObject) { |
1125 | try { |
1126 | DataValueDescriptor param = |
1127 | getParms().getParameterForGet(parameterIndex -1); |
1128 | if (param.isNull()) { |
1129 | break; |
1130 | } |
1131 | pushStack = true; |
1132 | setupContextStack(); |
1133 | |
1134 | StreamStorable ss = (StreamStorable)param; |
1135 | InputStream stream = ss.returnStream(); |
1136 | if (stream == null) { |
1137 | reader = new StringReader(param.getString()); |
1138 | } else { |
1139 | reader = new UTF8Reader(stream, 0, this, syncObject); |
1140 | } |
1141 | } catch (Throwable t) { |
1142 | throw EmbedResultSet.noStateChangeException(t); |
1143 | } finally { |
1144 | if (pushStack) { |
1145 | restoreContextStack(); |
1146 | } |
1147 | } |
1148 | } // End synchronized block |
1149 | break; |
1150 | |
1151 | // Handle binary types. |
1152 | // JDBC says to support these, but no defintion exists for the output. |
1153 | // Match JCC which treats the bytes as a UTF-16BE stream. |
1154 | case Types.BINARY: |
1155 | case Types.VARBINARY: |
1156 | case Types.LONGVARBINARY: |
1157 | case Types.BLOB: |
1158 | try { |
1159 | InputStream is = getBinaryStream(parameterIndex); |
1160 | if (is != null) { |
1161 | reader = new InputStreamReader(is, "UTF-16BE"); |
1162 | } |
1163 | break; |
1164 | } catch (UnsupportedEncodingException uee) { |
1165 | throw newSQLException(uee.getMessage()); |
1166 | } |
1167 | |
1168 | default: |
1169 | throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH, |
1170 | "java.io.Reader", Util.typeName(paramType)); |
1171 | } |
1172 | // Update wasNull. |
1173 | wasNull = (reader == null); |
1174 | return reader; |
1175 | } |
1176 | |
1177 | // Private utility classes |
1178 | |
1179 | /** |
1180 | * Get binary stream for a parameter. |
1181 | * |
1182 | * @param parameterIndex first parameter is 1, second is 2 etc. |
1183 | * @return a stream for the binary parameter, or <code>null</code>. |
1184 | * |
1185 | * @throws SQLException if a database access error occurs. |
1186 | */ |
1187 | private InputStream getBinaryStream(int parameterIndex) |
1188 | throws SQLException { |
1189 | int paramType = getParameterJDBCType(parameterIndex); |
1190 | switch (paramType) { |
1191 | case Types.BINARY: |
1192 | case Types.VARBINARY: |
1193 | case Types.LONGVARBINARY: |
1194 | case Types.BLOB: |
1195 | break; |
1196 | default: |
1197 | throw newSQLException(SQLState.LANG_DATA_TYPE_GET_MISMATCH, |
1198 | "java.io.InputStream", Util.typeName(paramType)); |
1199 | } |
1200 | |
1201 | boolean pushStack = false; |
1202 | synchronized (getConnectionSynchronization()) { |
1203 | try { |
1204 | DataValueDescriptor param = |
1205 | getParms().getParameterForGet(parameterIndex -1); |
1206 | wasNull = param.isNull(); |
1207 | if (wasNull) { |
1208 | return null; |
1209 | } |
1210 | pushStack = true; |
1211 | setupContextStack(); |
1212 | |
1213 | StreamStorable ss = (StreamStorable)param; |
1214 | InputStream stream = ss.returnStream(); |
1215 | if (stream == null) { |
1216 | stream = new ByteArrayInputStream(param.getBytes()); |
1217 | } else { |
1218 | stream = new BinaryToRawStream(stream, param); |
1219 | } |
1220 | return stream; |
1221 | } catch (Throwable t) { |
1222 | throw EmbedResultSet.noStateChangeException(t); |
1223 | } finally { |
1224 | if (pushStack) { |
1225 | restoreContextStack(); |
1226 | } |
1227 | } |
1228 | } // End synchronized block |
1229 | } |
1230 | } |