KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smallsql > database > SSCallableStatement


1 /* =============================================================
2  * SmallSQL : a free Java DBMS library for the Java(tm) platform
3  * =============================================================
4  *
5  * (C) Copyright 2004-2006, by Volker Berlin.
6  *
7  * Project Info: http://www.smallsql.de/
8  *
9  * This library is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22  * USA.
23  *
24  * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
25  * in the United States and other countries.]
26  *
27  * ---------------
28  * SSCallableStatament.java
29  * ---------------
30  * Author: Volker Berlin
31  *
32  */

33 package smallsql.database;
34
35 import java.sql.*;
36 import java.math.*;
37 import java.util.Map JavaDoc;
38 import java.util.Calendar JavaDoc;
39 import java.net.URL JavaDoc;
40 import java.io.*;
41
42
43 public class SSCallableStatement extends SSPreparedStatement implements CallableStatement {
44
45     private boolean wasNull;
46
47     SSCallableStatement( SSConnection con, String JavaDoc sql ) throws SQLException {
48         super( con, sql );
49     }
50
51     SSCallableStatement( SSConnection con, String JavaDoc sql, int rsType, int rsConcurrency ) throws SQLException {
52         super( con, sql, rsType, rsConcurrency );
53     }
54
55     private Expression getValue(int i) throws SQLException{
56         /**@todo: Implement this java.sql.CallableStatement method*/
57         throw new java.lang.UnsupportedOperationException JavaDoc("Method getValue() not yet implemented.");
58     }
59
60     private int findParameter( String JavaDoc parameterName ){
61         /**@todo: Implement this java.sql.CallableStatement method*/
62         throw new java.lang.UnsupportedOperationException JavaDoc("Method findParameter() not yet implemented.");
63     }
64 /*==============================================================================
65
66     Public Interface
67
68 ==============================================================================*/

69     public void registerOutParameter(int i, int sqlType) throws SQLException {
70         /**@todo: Implement this java.sql.CallableStatement method*/
71         throw new java.lang.UnsupportedOperationException JavaDoc("Method registerOutParameter() not yet implemented.");
72     }
73     public void registerOutParameter(int i, int sqlType, int scale) throws SQLException {
74         /**@todo: Implement this java.sql.CallableStatement method*/
75         throw new java.lang.UnsupportedOperationException JavaDoc("Method registerOutParameter() not yet implemented.");
76     }
77     
78     
79     public boolean wasNull(){
80         return wasNull;
81     }
82     
83     
84     public String JavaDoc getString(int i) throws SQLException {
85         try{
86             String JavaDoc obj = getValue(i).getString();
87             wasNull = obj == null;
88             return obj;
89         }catch(Exception JavaDoc e){
90             throw Utils.createSQLException( e );
91         }
92     }
93     public boolean getBoolean(int i) throws SQLException {
94         try{
95             Expression expr = getValue(i);
96             wasNull = expr.isNull();
97             return expr.getBoolean();
98         }catch(Exception JavaDoc e){
99             throw Utils.createSQLException( e );
100         }
101     }
102     public byte getByte(int i) throws SQLException {
103         return (byte)getInt( i );
104     }
105     public short getShort(int i) throws SQLException {
106         return (byte)getInt( i );
107     }
108     public int getInt(int i) throws SQLException {
109         try{
110             Expression expr = getValue(i);
111             wasNull = expr.isNull();
112             return expr.getInt();
113         }catch(Exception JavaDoc e){
114             throw Utils.createSQLException( e );
115         }
116     }
117     public long getLong(int i) throws SQLException {
118         try{
119             Expression expr = getValue(i);
120             wasNull = expr.isNull();
121             return expr.getLong();
122         }catch(Exception JavaDoc e){
123             throw Utils.createSQLException( e );
124         }
125     }
126     public float getFloat(int i) throws SQLException {
127         try{
128             Expression expr = getValue(i);
129             wasNull = expr.isNull();
130             return expr.getFloat();
131         }catch(Exception JavaDoc e){
132             throw Utils.createSQLException( e );
133         }
134     }
135     public double getDouble(int i) throws SQLException {
136         try{
137             Expression expr = getValue(i);
138             wasNull = expr.isNull();
139             return expr.getLong();
140         }catch(Exception JavaDoc e){
141             throw Utils.createSQLException( e );
142         }
143     }
144     public BigDecimal getBigDecimal(int i, int scale) throws SQLException {
145         try{
146             MutableNumeric obj = getValue(i).getNumeric();
147             wasNull = obj == null;
148             if(wasNull) return null;
149             return obj.toBigDecimal(scale);
150         }catch(Exception JavaDoc e){
151             throw Utils.createSQLException( e );
152         }
153     }
154     public byte[] getBytes(int i) throws SQLException {
155         try{
156             byte[] obj = getValue(i).getBytes();
157             wasNull = obj == null;
158             return obj;
159         }catch(Exception JavaDoc e){
160             throw Utils.createSQLException( e );
161         }
162     }
163     public Date getDate(int i) throws SQLException {
164         try{
165             Expression expr = getValue(i);
166             wasNull = expr.isNull();
167             if(wasNull) return null;
168             return DateTime.getDate( expr.getLong() );
169         }catch(Exception JavaDoc e){
170             throw Utils.createSQLException( e );
171         }
172     }
173     public Time getTime(int i) throws SQLException {
174         try{
175             Expression expr = getValue(i);
176             wasNull = expr.isNull();
177             if(wasNull) return null;
178             return DateTime.getTime( expr.getLong() );
179         }catch(Exception JavaDoc e){
180             throw Utils.createSQLException( e );
181         }
182     }
183     public Timestamp getTimestamp(int i) throws SQLException {
184         try{
185             Expression expr = getValue(i);
186             wasNull = expr.isNull();
187             if(wasNull) return null;
188             return DateTime.getTimestamp( expr.getLong() );
189         }catch(Exception JavaDoc e){
190             throw Utils.createSQLException( e );
191         }
192     }
193     public Object JavaDoc getObject(int i) throws SQLException {
194         try{
195             Object JavaDoc obj = getValue(i).getObject();
196             wasNull = obj == null;
197             return obj;
198         }catch(Exception JavaDoc e){
199             throw Utils.createSQLException( e );
200         }
201     }
202     public BigDecimal getBigDecimal(int i) throws SQLException {
203         try{
204             MutableNumeric obj = getValue(i).getNumeric();
205             wasNull = obj == null;
206             if(wasNull) return null;
207             return obj.toBigDecimal();
208         }catch(Exception JavaDoc e){
209             throw Utils.createSQLException( e );
210         }
211     }
212     public Object JavaDoc getObject(int i, Map JavaDoc map) throws SQLException {
213         /**@todo: Implement this java.sql.CallableStatement method*/
214         throw new java.lang.UnsupportedOperationException JavaDoc("Method getObject() not yet implemented.");
215     }
216     public Ref getRef(int i) throws SQLException {
217         /**@todo: Implement this java.sql.CallableStatement method*/
218         throw new java.lang.UnsupportedOperationException JavaDoc("Method getRef() not yet implemented.");
219     }
220     public Blob getBlob(int i) throws SQLException {
221         /**@todo: Implement this java.sql.CallableStatement method*/
222         throw new java.lang.UnsupportedOperationException JavaDoc("Method getBlob() not yet implemented.");
223     }
224     public Clob getClob(int i) throws SQLException {
225         /**@todo: Implement this java.sql.CallableStatement method*/
226         throw new java.lang.UnsupportedOperationException JavaDoc("Method getClob() not yet implemented.");
227     }
228     public Array getArray(int i) throws SQLException {
229         /**@todo: Implement this java.sql.CallableStatement method*/
230         throw new java.lang.UnsupportedOperationException JavaDoc("Method getArray() not yet implemented.");
231     }
232     public Date getDate(int i, Calendar JavaDoc cal) throws SQLException {
233         /**@todo: Implement this java.sql.CallableStatement method*/
234         throw new java.lang.UnsupportedOperationException JavaDoc("Method getDate() not yet implemented.");
235     }
236     public Time getTime(int i, Calendar JavaDoc cal) throws SQLException {
237         /**@todo: Implement this java.sql.CallableStatement method*/
238         throw new java.lang.UnsupportedOperationException JavaDoc("Method getTime() not yet implemented.");
239     }
240     public Timestamp getTimestamp(int i, Calendar JavaDoc cal) throws SQLException {
241         /**@todo: Implement this java.sql.CallableStatement method*/
242         throw new java.lang.UnsupportedOperationException JavaDoc("Method getTimestamp() not yet implemented.");
243     }
244     public void registerOutParameter(int i, int sqlType, String JavaDoc typeName) throws SQLException {
245         /**@todo: Implement this java.sql.CallableStatement method*/
246         throw new java.lang.UnsupportedOperationException JavaDoc("Method registerOutParameter() not yet implemented.");
247     }
248     public void registerOutParameter(String JavaDoc parameterName, int sqlType) throws SQLException {
249         registerOutParameter( findParameter( parameterName ), sqlType );
250     }
251     public void registerOutParameter(String JavaDoc parameterName, int sqlType, int scale) throws SQLException {
252         registerOutParameter( findParameter( parameterName ), sqlType, scale );
253     }
254     public void registerOutParameter(String JavaDoc parameterName, int sqlType, String JavaDoc typeName) throws SQLException {
255         registerOutParameter( findParameter( parameterName ), sqlType, typeName );
256     }
257     public URL JavaDoc getURL(int parameterIndex) throws SQLException {
258         /**@todo: Implement this java.sql.CallableStatement method*/
259         throw new java.lang.UnsupportedOperationException JavaDoc("Method getURL() not yet implemented.");
260     }
261     public void setURL(String JavaDoc parameterName, URL JavaDoc x) throws SQLException {
262         setURL( findParameter( parameterName ), x );
263     }
264     public void setNull(String JavaDoc parameterName, int sqlType) throws SQLException {
265         setNull( findParameter( parameterName ), sqlType );
266     }
267     public void setBoolean(String JavaDoc parameterName, boolean x) throws SQLException {
268         setBoolean( findParameter( parameterName ), x );
269     }
270     public void setByte(String JavaDoc parameterName, byte x) throws SQLException {
271         setByte( findParameter( parameterName ), x );
272     }
273     public void setShort(String JavaDoc parameterName, short x) throws SQLException {
274         setShort( findParameter( parameterName ), x );
275     }
276     public void setInt(String JavaDoc parameterName, int x) throws SQLException {
277         setInt( findParameter( parameterName ), x );
278     }
279     public void setLong(String JavaDoc parameterName, long x) throws SQLException {
280         setLong( findParameter( parameterName ), x );
281     }
282     public void setFloat(String JavaDoc parameterName, float x) throws SQLException {
283         setFloat( findParameter( parameterName ), x );
284     }
285     public void setDouble(String JavaDoc parameterName, double x) throws SQLException {
286         setDouble( findParameter( parameterName ), x );
287     }
288     public void setBigDecimal(String JavaDoc parameterName, BigDecimal x) throws SQLException {
289         setBigDecimal( findParameter( parameterName ), x );
290     }
291     public void setString(String JavaDoc parameterName, String JavaDoc x) throws SQLException {
292         setString( findParameter( parameterName ), x );
293     }
294     public void setBytes(String JavaDoc parameterName, byte[] x) throws SQLException {
295         setBytes( findParameter( parameterName ), x );
296     }
297     public void setDate(String JavaDoc parameterName, Date x) throws SQLException {
298         setDate( findParameter( parameterName ), x );
299     }
300     public void setTime(String JavaDoc parameterName, Time x) throws SQLException {
301         setTime( findParameter( parameterName ), x );
302     }
303     public void setTimestamp(String JavaDoc parameterName, Timestamp x) throws SQLException {
304         setTimestamp( findParameter( parameterName ), x );
305     }
306     public void setAsciiStream(String JavaDoc parameterName, InputStream x, int length) throws SQLException {
307         setAsciiStream( findParameter( parameterName ), x, length );
308     }
309     public void setBinaryStream(String JavaDoc parameterName, InputStream x, int length) throws SQLException {
310         setBinaryStream( findParameter( parameterName ), x, length );
311     }
312     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int sqlType, int scale) throws SQLException {
313         setObject( findParameter( parameterName ), x, sqlType, scale );
314     }
315     public void setObject(String JavaDoc parameterName, Object JavaDoc x, int sqlType) throws SQLException {
316         setObject( findParameter( parameterName ), x, sqlType );
317     }
318     public void setObject(String JavaDoc parameterName, Object JavaDoc x) throws SQLException {
319         setObject( findParameter( parameterName ), x );
320     }
321     public void setCharacterStream(String JavaDoc parameterName, Reader x, int length) throws SQLException {
322         setCharacterStream( findParameter( parameterName ), x, length );
323     }
324     public void setDate(String JavaDoc parameterName, Date x, Calendar JavaDoc cal) throws SQLException {
325         setDate( findParameter( parameterName ), x, cal );
326     }
327     public void setTime(String JavaDoc parameterName, Time x, Calendar JavaDoc cal) throws SQLException {
328         setTime( findParameter( parameterName ), x, cal );
329     }
330     public void setTimestamp(String JavaDoc parameterName, Timestamp x, Calendar JavaDoc cal) throws SQLException {
331         setTimestamp( findParameter( parameterName ), x, cal );
332     }
333     public void setNull(String JavaDoc parameterName, int sqlType, String JavaDoc typeName) throws SQLException {
334         setNull( findParameter( parameterName ), sqlType, typeName );
335     }
336     public String JavaDoc getString(String JavaDoc parameterName) throws SQLException {
337         return getString( findParameter( parameterName ) );
338     }
339     public boolean getBoolean(String JavaDoc parameterName) throws SQLException {
340         return getBoolean( findParameter( parameterName ) );
341     }
342     public byte getByte(String JavaDoc parameterName) throws SQLException {
343         return getByte( findParameter( parameterName ) );
344     }
345     public short getShort(String JavaDoc parameterName) throws SQLException {
346         return getShort( findParameter( parameterName ) );
347     }
348     public int getInt(String JavaDoc parameterName) throws SQLException {
349         return getInt( findParameter( parameterName ) );
350     }
351     public long getLong(String JavaDoc parameterName) throws SQLException {
352         return getLong( findParameter( parameterName ) );
353     }
354     public float getFloat(String JavaDoc parameterName) throws SQLException {
355         return getFloat( findParameter( parameterName ) );
356     }
357     public double getDouble(String JavaDoc parameterName) throws SQLException {
358         return getDouble( findParameter( parameterName ) );
359     }
360     public byte[] getBytes(String JavaDoc parameterName) throws SQLException {
361         return getBytes( findParameter( parameterName ) );
362     }
363     public Date getDate(String JavaDoc parameterName) throws SQLException {
364         return getDate( findParameter( parameterName ) );
365     }
366     public Time getTime(String JavaDoc parameterName) throws SQLException {
367         return getTime( findParameter( parameterName ) );
368     }
369     public Timestamp getTimestamp(String JavaDoc parameterName) throws SQLException {
370         return getTimestamp( findParameter( parameterName ) );
371     }
372     public Object JavaDoc getObject(String JavaDoc parameterName) throws SQLException {
373         return getObject( findParameter( parameterName ) );
374     }
375     public BigDecimal getBigDecimal(String JavaDoc parameterName) throws SQLException {
376         return getBigDecimal( findParameter( parameterName ) );
377     }
378     public Object JavaDoc getObject(String JavaDoc parameterName, Map JavaDoc map) throws SQLException {
379         return getObject( findParameter( parameterName ), map );
380     }
381     public Ref getRef(String JavaDoc parameterName) throws SQLException {
382         return getRef( findParameter( parameterName ) );
383     }
384     public Blob getBlob(String JavaDoc parameterName) throws SQLException {
385         return getBlob( findParameter( parameterName ) );
386     }
387     public Clob getClob(String JavaDoc parameterName) throws SQLException {
388         return getClob( findParameter( parameterName ) );
389     }
390     public Array getArray(String JavaDoc parameterName) throws SQLException {
391         return getArray( findParameter( parameterName ) );
392     }
393     public Date getDate(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
394         return getDate( findParameter( parameterName ), cal );
395     }
396     public Time getTime(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
397         return getTime( findParameter( parameterName ), cal );
398     }
399     public Timestamp getTimestamp(String JavaDoc parameterName, Calendar JavaDoc cal) throws SQLException {
400         return getTimestamp( findParameter( parameterName ), cal );
401     }
402     public URL JavaDoc getURL(String JavaDoc parameterName) throws SQLException {
403         return getURL( findParameter( parameterName ) );
404     }
405 }
Popular Tags