KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > connection > CallableStatementImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * ConnectionImpl.java
26  *
27  * Create on March 3, 2000
28  */

29
30 package com.sun.jdo.spi.persistence.support.sqlstore.connection;
31
32 import java.math.BigDecimal JavaDoc;
33 import java.sql.*;
34 import java.net.URL JavaDoc;
35 import java.util.Calendar JavaDoc;
36 import java.util.Map JavaDoc;
37 import java.io.InputStream JavaDoc;
38 import java.io.Reader JavaDoc;
39
40
41
42 /**
43  * This class implements the <code>java.sql.CallableStatement</code>
44  * interface, which is part of the JDBC API. You should use
45  * the <code>java.sql.CallableStatement</code> interface as an object
46  * type instead of this class.
47  */

48 public class CallableStatementImpl extends PreparedStatementImpl
49         implements CallableStatement {
50     //
51
// Keep references to corresponding JDBC Connection and
52
// CallableStatement objects.
53
//
54
// @param conn ConnectionImpl
55
// @param cstmt CallableStatement
56
//
57
public CallableStatementImpl(ConnectionImpl conn,
58                                  CallableStatement cstmt) {
59         super();
60         this.conn = conn;
61         this.stmt = (Statement) cstmt;
62     }
63
64     //----------------------------------------------------------------------
65
// Wrapper methods for JDBC CallableStatement:
66

67     public void registerOutParameter(int parameterIndex, int sqlType)
68             throws SQLException {
69         try {
70             CallableStatement cstmt = (CallableStatement) this.stmt;
71             cstmt.registerOutParameter(parameterIndex, sqlType);
72         } catch (SQLException se) {
73             throw se;
74         }
75     }
76
77     public void registerOutParameter(int parameterIndex, int sqlType, int scale)
78             throws SQLException {
79         try {
80             CallableStatement cstmt = (CallableStatement) this.stmt;
81             cstmt.registerOutParameter(parameterIndex, sqlType, scale);
82         } catch (SQLException se) {
83             throw se;
84         }
85     }
86
87     public boolean wasNull() throws SQLException {
88         CallableStatement cstmt = (CallableStatement) this.stmt;
89
90         try {
91             return (cstmt.wasNull());
92         } catch (SQLException se) {
93             throw se;
94         }
95     }
96
97     public String JavaDoc getString(int parameterIndex) throws SQLException {
98         try {
99             CallableStatement cstmt = (CallableStatement) this.stmt;
100             return (cstmt.getString(parameterIndex));
101         } catch (SQLException se) {
102             throw se;
103         }
104     }
105
106     public boolean getBoolean(int parameterIndex) throws SQLException {
107         try {
108             CallableStatement cstmt = (CallableStatement) this.stmt;
109             return (cstmt.getBoolean(parameterIndex));
110         } catch (SQLException se) {
111             throw se;
112         }
113     }
114
115     public byte getByte(int parameterIndex) throws SQLException {
116         try {
117             CallableStatement cstmt = (CallableStatement) this.stmt;
118             return (cstmt.getByte(parameterIndex));
119         } catch (SQLException se) {
120             throw se;
121         }
122     }
123
124     public short getShort(int parameterIndex) throws SQLException {
125         try {
126             CallableStatement cstmt = (CallableStatement) this.stmt;
127             return (cstmt.getShort(parameterIndex));
128         } catch (SQLException se) {
129             throw se;
130         }
131     }
132
133     public int getInt(int parameterIndex) throws SQLException {
134         CallableStatement cstmt = (CallableStatement) this.stmt;
135
136         try {
137             return (cstmt.getShort(parameterIndex));
138         } catch (SQLException se) {
139             throw se;
140         }
141     }
142
143     public long getLong(int parameterIndex) throws SQLException {
144         try {
145             CallableStatement cstmt = (CallableStatement) this.stmt;
146             return (cstmt.getLong(parameterIndex));
147         } catch (SQLException se) {
148             throw se;
149         }
150     }
151
152     public float getFloat(int parameterIndex) throws SQLException {
153         try {
154             CallableStatement cstmt = (CallableStatement) this.stmt;
155             return (cstmt.getFloat(parameterIndex));
156         } catch (SQLException se) {
157             throw se;
158         }
159     }
160
161     public double getDouble(int parameterIndex) throws SQLException {
162         try {
163             CallableStatement cstmt = (CallableStatement) this.stmt;
164             return (cstmt.getDouble(parameterIndex));
165         } catch (SQLException se) {
166             throw se;
167         }
168     }
169
170     public BigDecimal JavaDoc getBigDecimal(int parameterIndex, int scale)
171             throws SQLException {
172         try {
173             CallableStatement cstmt = (CallableStatement) this.stmt;
174             return (cstmt.getBigDecimal(parameterIndex, scale));
175         } catch (SQLException se) {
176             throw se;
177         }
178     }
179
180     public byte[] getBytes(int parameterIndex) throws SQLException {
181         try {
182             CallableStatement cstmt = (CallableStatement) this.stmt;
183             return (cstmt.getBytes(parameterIndex));
184         } catch (SQLException se) {
185             throw se;
186         }
187     }
188
189     public java.sql.Date JavaDoc getDate(int parameterIndex) throws SQLException {
190         try {
191             CallableStatement cstmt = (CallableStatement) this.stmt;
192             return (cstmt.getDate(parameterIndex));
193         } catch (SQLException se) {
194             throw se;
195         }
196     }
197
198     public java.sql.Time JavaDoc getTime(int parameterIndex) throws SQLException {
199         try {
200             CallableStatement cstmt = (CallableStatement) this.stmt;
201             return (cstmt.getTime(parameterIndex));
202         } catch (SQLException se) {
203             throw se;
204         }
205     }
206
207     public java.sql.Timestamp JavaDoc getTimestamp(int parameterIndex)
208             throws SQLException {
209         try {
210             CallableStatement cstmt = (CallableStatement) this.stmt;
211             return (cstmt.getTimestamp(parameterIndex));
212         } catch (SQLException se) {
213             throw se;
214         }
215     }
216
217     //----------------------------------------------------------------------
218
// Advanced features:
219

220
221     public Object JavaDoc getObject(int parameterIndex) throws SQLException {
222         try {
223             CallableStatement cstmt = (CallableStatement) this.stmt;
224             return (cstmt.getObject(parameterIndex));
225         } catch (SQLException se) {
226             throw se;
227         }
228     }
229
230     //--------------------------JDBC 2.0-----------------------------
231

232     public BigDecimal JavaDoc getBigDecimal(int parameterIndex) throws SQLException {
233         try {
234             CallableStatement cstmt = (CallableStatement) this.stmt;
235             return (cstmt.getBigDecimal(parameterIndex));
236         } catch (SQLException se) {
237             throw se;
238         }
239     }
240
241     public Object JavaDoc getObject(int i, java.util.Map JavaDoc map) throws SQLException {
242         try {
243             CallableStatement cstmt = (CallableStatement) this.stmt;
244             return (cstmt.getObject(i, map));
245         } catch (SQLException se) {
246             throw se;
247         }
248     }
249
250     public Ref getRef(int i) throws SQLException {
251         try {
252             CallableStatement cstmt = (CallableStatement) this.stmt;
253             return (cstmt.getRef(i));
254         } catch (SQLException se) {
255             throw se;
256         }
257     }
258
259     public int getResultSetConcurrency() throws SQLException {
260         return 0;
261     }
262
263 // JDK1.2FCS
264

265     public void registerOutParameter(int i, int j, String JavaDoc str) throws SQLException {
266         /* Comment out for now.
267         try
268         {
269             // CallableStatement cstmt = (CallableStatement) this.stmt;
270             // cstmt.registerOutParameter(i, j, str);
271         }
272         catch (SQLException se)
273         {
274             throw se;
275         }
276         */

277     }
278
279
280     //-------------Begin New methods added in JDBC 3.0 --------------
281
public void registerOutParameter(String JavaDoc parameterName,int sqlType) throws SQLException {
282
283         try {
284             CallableStatement cstmt = (CallableStatement) this.stmt;
285             cstmt.registerOutParameter(parameterName,sqlType);
286         } catch (SQLException se) {
287             throw se;
288         }
289
290     }
291
292     public void registerOutParameter(String JavaDoc parameterName,int sqlType,int scale)
293                                                                     throws SQLException {
294         try {
295             CallableStatement cstmt = (CallableStatement) this.stmt;
296             cstmt.registerOutParameter(parameterName,sqlType,scale);
297         } catch (SQLException se) {
298             throw se;
299         }
300
301     }
302
303     public void registerOutParameter(String JavaDoc parameterName,int sqlType,String JavaDoc typeName)
304                                                                      throws SQLException {
305         try {
306             CallableStatement cstmt = (CallableStatement) this.stmt;
307             cstmt.registerOutParameter(parameterName,sqlType,typeName);
308         } catch (SQLException se) {
309             throw se;
310         }
311
312     }
313
314     public java.net.URL JavaDoc getURL(int parameterIndex) throws SQLException {
315
316         throw new UnsupportedOperationException JavaDoc();
317     }
318
319     public void setURL(String JavaDoc parameterName,URL JavaDoc val) throws SQLException {
320
321         throw new UnsupportedOperationException JavaDoc();
322     }
323
324     public void setNull(String JavaDoc parameterName,int sqlType) throws SQLException {
325
326         throw new UnsupportedOperationException JavaDoc();
327     }
328
329     public void setBoolean(String JavaDoc parameterName, boolean x) throws SQLException {
330
331         throw new UnsupportedOperationException JavaDoc();
332     }
333
334     public void setByte(String JavaDoc parameterName, byte x) throws SQLException {
335
336         throw new UnsupportedOperationException JavaDoc();
337     }
338
339     public void setShort(String JavaDoc parameterName, short x) throws SQLException {
340
341         throw new UnsupportedOperationException JavaDoc();
342     }
343
344     public void setInt(String JavaDoc parameterName, int x) throws SQLException {
345
346         throw new UnsupportedOperationException JavaDoc();
347     }
348
349     public void setLong(String JavaDoc parameterName, long x) throws SQLException {
350
351         throw new UnsupportedOperationException JavaDoc();
352     }
353
354     public void setFloat(String JavaDoc parameterName, float x) throws SQLException {
355
356         throw new UnsupportedOperationException JavaDoc();
357     }
358
359     public void setDouble(String JavaDoc parameterName, double x) throws SQLException {
360
361         throw new UnsupportedOperationException JavaDoc();
362     }
363
364     public void setBigDecimal(String JavaDoc parameterName, BigDecimal JavaDoc x) throws SQLException {
365
366         throw new UnsupportedOperationException JavaDoc();
367     }
368
369     public void setString(String JavaDoc parameterName, String JavaDoc x) throws SQLException {
370
371         throw new UnsupportedOperationException JavaDoc();
372     }
373
374     public void setBytes(String JavaDoc parameterName, byte[] x) throws SQLException {
375
376         throw new UnsupportedOperationException JavaDoc();
377     }
378
379     public void setDate(String JavaDoc parameterName, Date x) throws SQLException {
380
381         throw new UnsupportedOperationException JavaDoc();
382     }
383
384     public void setTime(String JavaDoc parameterName, Time x) throws SQLException {
385
386         throw new UnsupportedOperationException JavaDoc();
387     }
388
389     public void setTimestamp(String JavaDoc parameterName, Timestamp x) throws SQLException {
390
391         throw new UnsupportedOperationException JavaDoc();
392     }
393
394     public void setAsciiStream(String JavaDoc parameterName, InputStream JavaDoc x, int length)
395                                                                 throws SQLException {
396         throw new UnsupportedOperationException JavaDoc();
397     }
398
399     public void setBinaryStream(String JavaDoc parameterName, InputStream JavaDoc x, int length)
400                                                                 throws SQLException {
401         throw new UnsupportedOperationException JavaDoc();
402     }
403
404     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType, int scale)
405                                                                  throws SQLException {
406         throw new UnsupportedOperationException JavaDoc();
407     }
408
409     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int targetSqlType)
410                                                                  throws SQLException {
411         throw new UnsupportedOperationException JavaDoc();
412     }
413
414     public void setObject(String JavaDoc parameterName, Object JavaDoc x) throws SQLException {
415
416         throw new UnsupportedOperationException JavaDoc();
417     }
418
419     public void setCharacterStream(String JavaDoc parameterName, Reader JavaDoc reader, int length)
420                                                                    throws SQLException {
421         throw new UnsupportedOperationException JavaDoc();
422     }
423
424     public void setDate(String JavaDoc parameterName, Date x, Calendar JavaDoc cal) throws SQLException {
425
426         throw new UnsupportedOperationException JavaDoc();
427     }
428
429     public void setTime(String JavaDoc parameterName, Time x, Calendar JavaDoc cal) throws SQLException {
430
431         throw new UnsupportedOperationException JavaDoc();
432     }
433
434     public void setTimestamp(String JavaDoc parameterName, Timestamp x, Calendar JavaDoc cal)
435                                                                     throws SQLException {
436
437         throw new UnsupportedOperationException JavaDoc();
438     }
439
440     public void setNull(String JavaDoc parameterName, int sqlType, String JavaDoc typeName)
441                                                                     throws SQLException {
442         throw new UnsupportedOperationException JavaDoc();
443     }
444
445     public String JavaDoc getString(String JavaDoc parameterName) throws SQLException {
446         try {
447             CallableStatement cstmt = (CallableStatement) this.stmt;
448             return (cstmt.getString(parameterName));
449         } catch (SQLException se) {
450             throw se;
451         }
452     }
453
454     public boolean getBoolean(String JavaDoc parameterName) throws SQLException {
455         try {
456             CallableStatement cstmt = (CallableStatement) this.stmt;
457             return (cstmt.getBoolean(parameterName));
458         } catch (SQLException se) {
459             throw se;
460         }
461     }
462
463     public byte getByte(String JavaDoc parameterName) throws SQLException {
464         try {
465             CallableStatement cstmt = (CallableStatement) this.stmt;
466             return (cstmt.getByte(parameterName));
467         } catch (SQLException se) {
468             throw se;
469         }
470     }
471
472     public short getShort(String JavaDoc parameterName) throws SQLException {
473         try {
474             CallableStatement cstmt = (CallableStatement) this.stmt;
475             return (cstmt.getShort(parameterName));
476         } catch (SQLException se) {
477             throw se;
478         }
479     }
480
481     public int getInt(String JavaDoc parameterName) throws SQLException {
482         try {
483             CallableStatement cstmt = (CallableStatement) this.stmt;
484             return (cstmt.getInt(parameterName));
485         } catch (SQLException se) {
486             throw se;
487         }
488     }
489
490     public long getLong(String JavaDoc parameterName) throws SQLException {
491         try {
492             CallableStatement cstmt = (CallableStatement) this.stmt;
493             return (cstmt.getLong(parameterName));
494         } catch (SQLException se) {
495             throw se;
496         }
497     }
498
499     public float getFloat(String JavaDoc parameterName) throws SQLException {
500         try {
501             CallableStatement cstmt = (CallableStatement) this.stmt;
502             return (cstmt.getFloat(parameterName));
503         } catch (SQLException se) {
504             throw se;
505         }
506     }
507
508     public double getDouble(String JavaDoc parameterName) throws SQLException {
509         try {
510             CallableStatement cstmt = (CallableStatement) this.stmt;
511             return (cstmt.getDouble(parameterName));
512         } catch (SQLException se) {
513             throw se;
514         }
515     }
516
517     public byte[] getBytes(String JavaDoc parameterName) throws SQLException {
518         try {
519             CallableStatement cstmt = (CallableStatement) this.stmt;
520             return (cstmt.getBytes(parameterName));
521         } catch (SQLException se) {
522             throw se;
523         }
524     }
525
526     public Date getDate(String JavaDoc parameterName) throws SQLException {
527         try {
528             CallableStatement cstmt = (CallableStatement) this.stmt;
529             return (cstmt.getDate(parameterName));
530         } catch (SQLException se) {
531             throw se;
532         }
533     }
534
535     public Time getTime(String JavaDoc parameterName) throws SQLException {
536         try {
537             CallableStatement cstmt = (CallableStatement) this.stmt;
538             return (cstmt.getTime(parameterName));
539         } catch (SQLException se) {
540             throw se;
541         }
542     }
543
544     public Timestamp getTimestamp(String JavaDoc parameterName) throws SQLException {
545         try {
546             CallableStatement cstmt = (CallableStatement) this.stmt;
547             return (cstmt.getTimestamp(parameterName));
548         } catch (SQLException se) {
549             throw se;
550         }
551     }
552
553     public Object JavaDoc getObject(String JavaDoc parameterName) throws SQLException {
554         try {
555             CallableStatement cstmt = (CallableStatement) this.stmt;
556             return (cstmt.getObject(parameterName));
557         } catch (SQLException se) {
558             throw se;
559         }
560     }
561
562     public BigDecimal JavaDoc getBigDecimal(String JavaDoc parameterName) throws SQLException {
563         try {
564             CallableStatement cstmt = (CallableStatement) this.stmt;
565             return (cstmt.getBigDecimal(parameterName));
566         } catch (SQLException se) {
567             throw se;
568         }
569     }
570
571     public Object JavaDoc getObject(String JavaDoc parameterName, Map JavaDoc map) throws SQLException {
572         try {
573             CallableStatement cstmt = (CallableStatement) this.stmt;
574             return (cstmt.getObject(parameterName,map));
575         } catch (SQLException se) {
576             throw se;
577         }
578     }
579
580     public Ref getRef(String JavaDoc parameterName) throws SQLException {
581         try {
582             CallableStatement cstmt = (CallableStatement) this.stmt;
583             return (cstmt.getRef(parameterName));
584         } catch (SQLException se) {
585             throw se;
586         }
587     }
588
589     public Blob getBlob(String JavaDoc parameterName) throws SQLException {
590         try {
591             CallableStatement cstmt = (CallableStatement) this.stmt;
592             return (cstmt.getBlob(parameterName));
593         } catch (SQLException se) {
594             throw se;
595         }
596     }
597
598     public Clob getClob(String JavaDoc parameterName) throws SQLException {
599         try {
600             CallableStatement cstmt = (CallableStatement) this.stmt;
601             return (cstmt.getClob(parameterName));
602         } catch (SQLException se) {
603             throw se;
604         }
605     }
606
607     public Array getArray(String JavaDoc parameterName) throws SQLException {
608         try {
609             CallableStatement cstmt = (CallableStatement) this.stmt;
610             return (cstmt.getArray(parameterName));
611         } catch (SQLException se) {
612             throw se;
613         }
614     }
615
616     public Date getDate(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
617         try {
618             CallableStatement cstmt = (CallableStatement) this.stmt;
619             return (cstmt.getDate(parameterName,cal));
620         } catch (SQLException se) {
621             throw se;
622         }
623     }
624
625     public Time getTime(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
626         try {
627             CallableStatement cstmt = (CallableStatement) this.stmt;
628             return (cstmt.getTime(parameterName,cal));
629         } catch (SQLException se) {
630             throw se;
631         }
632     }
633
634     public Timestamp getTimestamp(String JavaDoc parameterName, Calendar JavaDoc cal)
635                                                              throws SQLException {
636         try {
637             CallableStatement cstmt = (CallableStatement) this.stmt;
638             return (cstmt.getTimestamp(parameterName,cal));
639         } catch (SQLException se) {
640             throw se;
641         }
642     }
643
644     public URL JavaDoc getURL(String JavaDoc parameterName) throws SQLException {
645         try {
646             CallableStatement cstmt = (CallableStatement) this.stmt;
647             return (cstmt.getURL(parameterName));
648         } catch (SQLException se) {
649             throw se;
650         }
651     }
652
653     //-------------End New methods added in JDBC 3.0 --------------
654

655 }
656
Popular Tags