KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mysql > jdbc > CallableStatement


1 /*
2  Copyright (C) 2002-2004 MySQL AB
3
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of version 2 of the GNU General Public License as
6  published by the Free Software Foundation.
7
8  There are special exceptions to the terms and conditions of the GPL
9  as it is applied to this software. View the full text of the
10  exception in file EXCEPTIONS-CONNECTOR-J in the directory of this
11  software distribution.
12
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22
23
24  */

25 package com.mysql.jdbc;
26
27 import java.io.InputStream JavaDoc;
28 import java.io.Reader JavaDoc;
29
30 import java.math.BigDecimal JavaDoc;
31
32 import java.net.URL JavaDoc;
33
34 import java.sql.Array JavaDoc;
35 import java.sql.Blob JavaDoc;
36 import java.sql.Clob JavaDoc;
37 import java.sql.Date JavaDoc;
38 import java.sql.ParameterMetaData JavaDoc;
39 import java.sql.Ref JavaDoc;
40 import java.sql.SQLException JavaDoc;
41 import java.sql.Time JavaDoc;
42 import java.sql.Timestamp JavaDoc;
43 import java.sql.Types JavaDoc;
44
45 import java.util.ArrayList JavaDoc;
46 import java.util.Calendar JavaDoc;
47 import java.util.HashMap JavaDoc;
48 import java.util.Iterator JavaDoc;
49 import java.util.List JavaDoc;
50 import java.util.Locale JavaDoc;
51 import java.util.Map JavaDoc;
52
53 /**
54  * Representation of stored procedures for JDBC
55  *
56  * @author Mark Matthews
57  * @version $Id: CallableStatement.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews
58  * Exp $
59  */

60 public class CallableStatement extends PreparedStatement implements
61         java.sql.CallableStatement JavaDoc {
62     class CallableStatementParam {
63         int desiredJdbcType;
64
65         int index;
66
67         boolean isIn;
68
69         boolean isOut;
70
71         String JavaDoc paramName;
72
73         int jdbcType;
74         String JavaDoc typeName;
75         int precision;
76         int scale;
77         short nullability;
78         int inOutModifier;
79         
80         CallableStatementParam(String JavaDoc name, int idx, boolean in,
81                 boolean out, int jdbcType, String JavaDoc typeName,
82                 int precision, int scale, short nullability,
83                 int inOutModifier) {
84             this.paramName = name;
85             this.isIn = in;
86             this.isOut = out;
87             this.index = idx;
88             
89             this.jdbcType = jdbcType;
90             this.typeName = typeName;
91             this.precision = precision;
92             this.scale = scale;
93             this.nullability = nullability;
94             this.inOutModifier = inOutModifier;
95         }
96
97         /*
98          * (non-Javadoc)
99          *
100          * @see java.lang.Object#clone()
101          */

102         protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
103             return super.clone();
104         }
105     }
106
107     class CallableStatementParamInfo implements ParameterMetaData JavaDoc {
108         String JavaDoc catalogInUse;
109
110         boolean isFunctionCall;
111
112         String JavaDoc nativeSql;
113
114         int numParameters;
115
116         List JavaDoc parameterList;
117
118         Map JavaDoc parameterMap;
119
120         CallableStatementParamInfo(java.sql.ResultSet JavaDoc paramTypesRs)
121                 throws SQLException JavaDoc {
122             boolean hadRows = paramTypesRs.last();
123
124             this.nativeSql = originalSql;
125             this.catalogInUse = currentCatalog;
126             isFunctionCall = callingStoredFunction;
127
128             if (hadRows) {
129                 this.numParameters = paramTypesRs.getRow();
130
131                 this.parameterList = new ArrayList JavaDoc(this.numParameters);
132                 this.parameterMap = new HashMap JavaDoc(this.numParameters);
133
134                 paramTypesRs.beforeFirst();
135
136                 addParametersFromDBMD(paramTypesRs);
137             } else {
138                 this.numParameters = 0;
139             }
140         }
141
142         private void addParametersFromDBMD(java.sql.ResultSet JavaDoc paramTypesRs)
143                 throws SQLException JavaDoc {
144             int i = 0;
145
146             if (isFunctionCall) {
147                 // first row will be return value parameter
148
paramTypesRs.next();
149             }
150             
151             while (paramTypesRs.next()) {
152                 String JavaDoc paramName = paramTypesRs.getString(4);
153                 int inOutModifier = paramTypesRs.getInt(5);
154
155                 boolean isOutParameter = false;
156                 boolean isInParameter = false;
157
158                 if (inOutModifier == DatabaseMetaData.procedureColumnInOut) {
159                     isOutParameter = true;
160                     isInParameter = true;
161                 } else if (inOutModifier == DatabaseMetaData.procedureColumnIn) {
162                     isOutParameter = false;
163                     isInParameter = true;
164                 } else if (inOutModifier == DatabaseMetaData.procedureColumnOut) {
165                     isOutParameter = true;
166                     isInParameter = false;
167                 }
168                 
169                 int jdbcType = paramTypesRs.getInt(6);
170                 String JavaDoc typeName = paramTypesRs.getString(7);
171                 int precision = paramTypesRs.getInt(8);
172                 int scale = paramTypesRs.getInt(10);
173                 short nullability = paramTypesRs.getShort(12);
174
175                 CallableStatementParam paramInfoToAdd = new CallableStatementParam(
176                         paramName, i++, isInParameter, isOutParameter,
177                         jdbcType, typeName, precision, scale, nullability,
178                         inOutModifier);
179
180                 this.parameterList.add(paramInfoToAdd);
181                 this.parameterMap.put(paramName, paramInfoToAdd);
182             }
183         }
184
185         /*
186          * (non-Javadoc)
187          *
188          * @see java.lang.Object#clone()
189          */

190         protected Object JavaDoc clone() throws CloneNotSupportedException JavaDoc {
191             // TODO Auto-generated method stub
192
return super.clone();
193         }
194
195         CallableStatementParam getParameter(int index) {
196             return (CallableStatementParam) this.parameterList.get(index);
197         }
198
199         CallableStatementParam getParameter(String JavaDoc name) {
200             return (CallableStatementParam) this.parameterMap.get(name);
201         }
202
203         Iterator JavaDoc iterator() {
204             return this.parameterList.iterator();
205         }
206
207         int numberOfParameters() {
208             return this.numParameters;
209         }
210
211         public int getParameterCount() throws SQLException JavaDoc {
212             return this.parameterList.size();
213         }
214
215         public int isNullable(int arg0) throws SQLException JavaDoc {
216             checkBounds(arg0);
217             
218             return getParameter(arg0 - 1).nullability;
219         }
220
221         public boolean isSigned(int arg0) throws SQLException JavaDoc {
222             checkBounds(arg0);
223
224             return false;
225         }
226
227         public int getPrecision(int arg0) throws SQLException JavaDoc {
228             checkBounds(arg0);
229             
230             return getParameter(arg0 - 1).precision;
231         }
232
233         public int getScale(int arg0) throws SQLException JavaDoc {
234             checkBounds(arg0);
235             
236             return getParameter(arg0 - 1).scale;
237         }
238
239         public int getParameterType(int arg0) throws SQLException JavaDoc {
240             checkBounds(arg0);
241             
242             return getParameter(arg0 - 1).jdbcType;
243         }
244
245         public String JavaDoc getParameterTypeName(int arg0) throws SQLException JavaDoc {
246             checkBounds(arg0);
247             
248             return getParameter(arg0 - 1).typeName;
249         }
250
251         public String JavaDoc getParameterClassName(int arg0) throws SQLException JavaDoc {
252             // TODO Auto-generated method stub
253
return null;
254         }
255
256         public int getParameterMode(int arg0) throws SQLException JavaDoc {
257             checkBounds(arg0);
258             
259             return getParameter(arg0 - 1).inOutModifier;
260         }
261
262         protected void checkBounds(int paramIndex) throws SQLException JavaDoc {
263             int localParamIndex = paramIndex - 1;
264
265             if ((paramIndex < 0)
266                     || (localParamIndex >= this.numParameters)) {
267                 throw new SQLException JavaDoc(
268                         Messages.getString("CallableStatement.11") + paramIndex //$NON-NLS-1$
269
+ Messages.getString("CallableStatement.12") + numParameters //$NON-NLS-1$
270
+ Messages.getString("CallableStatement.13"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$
271
}
272         }
273     }
274     
275     private final static int NOT_OUTPUT_PARAMETER_INDICATOR = Integer.MIN_VALUE;
276
277     private final static String JavaDoc PARAMETER_NAMESPACE_PREFIX = "@com_mysql_jdbc_outparam_"; //$NON-NLS-1$
278

279     private static String JavaDoc mangleParameterName(String JavaDoc origParameterName) {
280         if (origParameterName == null) {
281             return null;
282         }
283
284         int offset = 0;
285
286         if (origParameterName.length() > 0
287                 && origParameterName.charAt(0) == '@') {
288             offset = 1;
289         }
290
291         StringBuffer JavaDoc paramNameBuf = new StringBuffer JavaDoc(PARAMETER_NAMESPACE_PREFIX
292                 .length()
293                 + origParameterName.length());
294         paramNameBuf.append(PARAMETER_NAMESPACE_PREFIX);
295         paramNameBuf.append(origParameterName.substring(offset));
296
297         return paramNameBuf.toString();
298     }
299
300     private boolean callingStoredFunction = false;
301
302     private ResultSet functionReturnValueResults;
303
304     private boolean hasOutputParams = false;
305
306     // private List parameterList;
307
// private Map parameterMap;
308
private ResultSet outputParameterResults;
309
310     private boolean outputParamWasNull = false;
311
312     private int[] parameterIndexToRsIndex;
313
314     protected CallableStatementParamInfo paramInfo;
315
316     private CallableStatementParam returnValueParam;
317
318     /**
319      * Creates a new CallableStatement
320      *
321      * @param conn
322      * the connection creating this statement
323      * @param paramInfo
324      * the SQL to prepare
325      *
326      * @throws SQLException
327      * if an error occurs
328      */

329     public CallableStatement(Connection conn,
330             CallableStatementParamInfo paramInfo) throws SQLException JavaDoc {
331         super(conn, paramInfo.nativeSql, paramInfo.catalogInUse);
332
333         this.paramInfo = paramInfo;
334         this.callingStoredFunction = this.paramInfo.isFunctionCall;
335     }
336
337     /**
338      * Creates a new CallableStatement
339      *
340      * @param conn
341      * the connection creating this statement
342      * @param catalog
343      * catalog the current catalog
344      *
345      * @throws SQLException
346      * if an error occurs
347      */

348     public CallableStatement(Connection conn, String JavaDoc catalog)
349             throws SQLException JavaDoc {
350         super(conn, catalog, null);
351
352         determineParameterTypes();
353     }
354
355     /**
356      * Creates a new CallableStatement
357      *
358      * @param conn
359      * the connection creating this statement
360      * @param sql
361      * the SQL to prepare
362      * @param catalog
363      * the current catalog
364      *
365      * @throws SQLException
366      * if an error occurs
367      */

368     public CallableStatement(Connection conn, String JavaDoc sql, String JavaDoc catalog,
369             boolean isFunctionCall) throws SQLException JavaDoc {
370         super(conn, sql, catalog);
371
372         this.callingStoredFunction = isFunctionCall;
373
374         determineParameterTypes();
375     }
376
377     /*
378      * (non-Javadoc)
379      *
380      * @see java.sql.PreparedStatement#addBatch()
381      */

382     public void addBatch() throws SQLException JavaDoc {
383         setOutParams();
384
385         super.addBatch();
386     }
387
388     private CallableStatementParam checkIsOutputParam(int paramIndex)
389             throws SQLException JavaDoc {
390
391         if (this.callingStoredFunction) {
392             if (paramIndex == 1) {
393
394                 if (this.returnValueParam == null) {
395                     this.returnValueParam = new CallableStatementParam("", 0,
396                             false, true, Types.VARCHAR, "VARCHAR", 0, 0,
397                             DatabaseMetaData.attributeNullableUnknown,
398                             DatabaseMetaData.procedureColumnReturn);
399                 }
400
401                 return this.returnValueParam;
402             }
403
404             // Move to position in output result set
405
paramIndex--;
406         }
407
408         checkParameterIndexBounds(paramIndex);
409
410         int localParamIndex = paramIndex - 1;
411
412         CallableStatementParam paramDescriptor = this.paramInfo
413                 .getParameter(localParamIndex);
414
415         if (!paramDescriptor.isOut) {
416             throw new SQLException JavaDoc(
417                     Messages.getString("CallableStatement.9") + paramIndex //$NON-NLS-1$
418
+ Messages.getString("CallableStatement.10"), //$NON-NLS-1$
419
SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
420         }
421
422         this.hasOutputParams = true;
423
424         return paramDescriptor;
425     }
426
427     /**
428      * DOCUMENT ME!
429      *
430      * @param paramIndex
431      *
432      * @throws SQLException
433      */

434     private void checkParameterIndexBounds(int paramIndex) throws SQLException JavaDoc {
435         this.paramInfo.checkBounds(paramIndex);
436     }
437
438     /**
439      * Checks whether or not this statement is supposed to be providing
440      * streamable result sets...If output parameters are registered, the driver
441      * can not stream the results.
442      *
443      * @throws SQLException
444      * DOCUMENT ME!
445      */

446     private void checkStreamability() throws SQLException JavaDoc {
447         if (this.hasOutputParams && createStreamingResultSet()) {
448             throw new SQLException JavaDoc(Messages.getString("CallableStatement.14"), //$NON-NLS-1$
449
SQLError.SQL_STATE_DRIVER_NOT_CAPABLE);
450         }
451     }
452
453     private void determineParameterTypes() throws SQLException JavaDoc {
454         java.sql.ResultSet JavaDoc paramTypesRs = null;
455
456         try {
457             String JavaDoc procName = extractProcedureName();
458
459             java.sql.DatabaseMetaData JavaDoc dbmd = this.connection.getMetaData();
460
461             boolean useCatalog = false;
462
463             if (procName.indexOf(".") == -1) {
464                 useCatalog = true;
465             }
466
467             paramTypesRs = dbmd.getProcedureColumns(this.connection
468                     .versionMeetsMinimum(5, 0, 2)
469                     & useCatalog ? this.currentCatalog : null, null, procName,
470                     "%"); //$NON-NLS-1$
471

472             this.paramInfo = new CallableStatementParamInfo(paramTypesRs);
473         } finally {
474             SQLException JavaDoc sqlExRethrow = null;
475
476             if (paramTypesRs != null) {
477                 try {
478                     paramTypesRs.close();
479                 } catch (SQLException JavaDoc sqlEx) {
480                     sqlExRethrow = sqlEx;
481                 }
482
483                 paramTypesRs = null;
484             }
485
486             if (sqlExRethrow != null) {
487                 throw sqlExRethrow;
488             }
489         }
490     }
491
492     /*
493      * (non-Javadoc)
494      *
495      * @see java.sql.PreparedStatement#execute()
496      */

497     public boolean execute() throws SQLException JavaDoc {
498         boolean returnVal = false;
499
500         checkClosed();
501
502         checkStreamability();
503
504         synchronized (this.connection.getMutex()) {
505             setInOutParamsOnServer();
506             setOutParams();
507
508             returnVal = super.execute();
509
510             if (this.callingStoredFunction) {
511                 this.functionReturnValueResults = this.results;
512                 this.functionReturnValueResults.next();
513                 this.results = null;
514             }
515
516             retrieveOutParams();
517         }
518
519         if (!this.callingStoredFunction) {
520             return returnVal;
521         }
522
523         // Functions can't return results
524
return false;
525     }
526
527     /*
528      * (non-Javadoc)
529      *
530      * @see java.sql.PreparedStatement#executeQuery()
531      */

532     public synchronized java.sql.ResultSet JavaDoc executeQuery() throws SQLException JavaDoc {
533         checkClosed();
534
535         checkStreamability();
536
537         java.sql.ResultSet JavaDoc execResults = null;
538
539         synchronized (this.connection.getMutex()) {
540             setInOutParamsOnServer();
541             setOutParams();
542
543             execResults = super.executeQuery();
544
545             retrieveOutParams();
546         }
547
548         return execResults;
549     }
550
551     /*
552      * (non-Javadoc)
553      *
554      * @see java.sql.PreparedStatement#executeUpdate()
555      */

556     public synchronized int executeUpdate() throws SQLException JavaDoc {
557         int returnVal = -1;
558
559         checkClosed();
560
561         checkStreamability();
562
563         if (this.callingStoredFunction) {
564             execute();
565
566             return -1;
567         }
568
569         synchronized (this.connection.getMutex()) {
570             setInOutParamsOnServer();
571             setOutParams();
572
573             returnVal = super.executeUpdate();
574
575             retrieveOutParams();
576         }
577
578         return returnVal;
579     }
580
581     private String JavaDoc extractProcedureName() throws SQLException JavaDoc {
582         // TODO: Do this with less memory allocation
583
int endCallIndex = StringUtils.indexOfIgnoreCase(this.originalSql,
584                 "CALL "); //$NON-NLS-1$
585
int offset = 5;
586
587         if (endCallIndex == -1) {
588             endCallIndex = StringUtils.indexOfIgnoreCase(this.originalSql,
589                     "SELECT ");
590             offset = 7;
591         }
592
593         if (endCallIndex != -1) {
594             StringBuffer JavaDoc nameBuf = new StringBuffer JavaDoc();
595
596             String JavaDoc trimmedStatement = this.originalSql.substring(
597                     endCallIndex + offset).trim();
598
599             int statementLength = trimmedStatement.length();
600
601             for (int i = 0; i < statementLength; i++) {
602                 char c = trimmedStatement.charAt(i);
603
604                 if (Character.isWhitespace(c) || (c == '(') || (c == '?')) {
605                     break;
606                 }
607                 nameBuf.append(c);
608
609             }
610
611             return nameBuf.toString();
612         }
613         throw new SQLException JavaDoc(Messages.getString("CallableStatement.1"), //$NON-NLS-1$
614
SQLError.SQL_STATE_GENERAL_ERROR);
615
616     }
617
618     /**
619      * Adds 'at' symbol to beginning of parameter names if needed.
620      *
621      * @param paramNameIn
622      * the parameter name to 'fix'
623      *
624      * @return the parameter name with an 'a' prepended, if needed
625      *
626      * @throws SQLException
627      * if the parameter name is null or empty.
628      */

629     private String JavaDoc fixParameterName(String JavaDoc paramNameIn) throws SQLException JavaDoc {
630         if ((paramNameIn == null) || (paramNameIn.length() == 0)) {
631             throw new SQLException JavaDoc(
632                     ((Messages.getString("CallableStatement.0") + paramNameIn) == null) //$NON-NLS-1$
633
? Messages.getString("CallableStatement.15") : Messages.getString("CallableStatement.16"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT); //$NON-NLS-1$ //$NON-NLS-2$
634
}
635
636         return mangleParameterName(paramNameIn);
637
638         /*
639          * if (paramNameIn.startsWith("@")) { return paramNameIn; } else {
640          * StringBuffer paramNameBuf = new StringBuffer("@");
641          * paramNameBuf.append(paramNameIn);
642          *
643          * return paramNameBuf.toString(); }
644          */

645     }
646
647     /**
648      * @see java.sql.CallableStatement#getArray(int)
649      */

650     public synchronized Array JavaDoc getArray(int i) throws SQLException JavaDoc {
651         ResultSet rs = getOutputParameters(i);
652
653         Array JavaDoc retValue = rs.getArray(mapOutputParameterIndexToRsIndex(i));
654
655         this.outputParamWasNull = rs.wasNull();
656
657         return retValue;
658     }
659
660     /**
661      * @see java.sql.CallableStatement#getArray(java.lang.String)
662      */

663     public synchronized Array JavaDoc getArray(String JavaDoc parameterName)
664             throws SQLException JavaDoc {
665         ResultSet rs = getOutputParameters(0); // definitely not going to be
666
// from ?=
667

668         Array JavaDoc retValue = rs.getArray(fixParameterName(parameterName));
669
670         this.outputParamWasNull = rs.wasNull();
671
672         return retValue;
673     }
674
675     /**
676      * @see java.sql.CallableStatement#getBigDecimal(int)
677      */

678     public synchronized BigDecimal JavaDoc getBigDecimal(int parameterIndex)
679             throws SQLException JavaDoc {
680         ResultSet rs = getOutputParameters(parameterIndex);
681
682         BigDecimal JavaDoc retValue = rs
683                 .getBigDecimal(mapOutputParameterIndexToRsIndex(parameterIndex));
684
685         this.outputParamWasNull = rs.wasNull();
686
687         return retValue;
688     }
689
690     /**
691      * DOCUMENT ME!
692      *
693      * @param parameterIndex
694      * DOCUMENT ME!
695      * @param scale
696      * DOCUMENT ME!
697      *
698      * @return DOCUMENT ME!
699      *
700      * @throws SQLException
701      * DOCUMENT ME!
702      *
703      * @see java.sql.CallableStatement#getBigDecimal(int, int)
704      * @deprecated
705      */

706     public synchronized BigDecimal JavaDoc getBigDecimal(int parameterIndex, int scale)
707             throws SQLException JavaDoc {
708         ResultSet rs = getOutputParameters(parameterIndex);
709
710         BigDecimal JavaDoc retValue = rs.getBigDecimal(
711                 mapOutputParameterIndexToRsIndex(parameterIndex), scale);
712
713         this.outputParamWasNull = rs.wasNull();
714
715         return retValue;
716     }
717
718     /**
719      * @see java.sql.CallableStatement#getBigDecimal(java.lang.String)
720      */

721     public synchronized BigDecimal JavaDoc getBigDecimal(String JavaDoc parameterName)
722             throws SQLException JavaDoc {
723         ResultSet rs = getOutputParameters(0); // definitely not going to be
724
// from ?=
725

726         BigDecimal JavaDoc retValue = rs.getBigDecimal(fixParameterName(parameterName));
727
728         this.outputParamWasNull = rs.wasNull();
729
730         return retValue;
731     }
732
733     /**
734      * @see java.sql.CallableStatement#getBlob(int)
735      */

736     public synchronized Blob getBlob(int parameterIndex) throws SQLException JavaDoc {
737         ResultSet rs = getOutputParameters(parameterIndex);
738
739         Blob retValue = rs
740                 .getBlob(mapOutputParameterIndexToRsIndex(parameterIndex));
741
742         this.outputParamWasNull = rs.wasNull();
743
744         return retValue;
745     }
746
747     /**
748      * @see java.sql.CallableStatement#getBlob(java.lang.String)
749      */

750     public synchronized Blob getBlob(String JavaDoc parameterName) throws SQLException JavaDoc {
751         ResultSet rs = getOutputParameters(0); // definitely not going to be
752
// from ?=
753

754         Blob retValue = rs.getBlob(fixParameterName(parameterName));
755
756         this.outputParamWasNull = rs.wasNull();
757
758         return retValue;
759     }
760
761     /**
762      * @see java.sql.CallableStatement#getBoolean(int)
763      */

764     public synchronized boolean getBoolean(int parameterIndex)
765             throws SQLException JavaDoc {
766         ResultSet rs = getOutputParameters(parameterIndex);
767
768         boolean retValue = rs
769                 .getBoolean(mapOutputParameterIndexToRsIndex(parameterIndex));
770
771         this.outputParamWasNull = rs.wasNull();
772
773         return retValue;
774     }
775
776     /**
777      * @see java.sql.CallableStatement#getBoolean(java.lang.String)
778      */

779     public synchronized boolean getBoolean(String JavaDoc parameterName)
780             throws SQLException JavaDoc {
781         ResultSet rs = getOutputParameters(0); // definitely not going to be
782
// from ?=
783

784         boolean retValue = rs.getBoolean(fixParameterName(parameterName));
785
786         this.outputParamWasNull = rs.wasNull();
787
788         return retValue;
789     }
790
791     /**
792      * @see java.sql.CallableStatement#getByte(int)
793      */

794     public synchronized byte getByte(int parameterIndex) throws SQLException JavaDoc {
795         ResultSet rs = getOutputParameters(parameterIndex);
796
797         byte retValue = rs
798                 .getByte(mapOutputParameterIndexToRsIndex(parameterIndex));
799
800         this.outputParamWasNull = rs.wasNull();
801
802         return retValue;
803     }
804
805     /**
806      * @see java.sql.CallableStatement#getByte(java.lang.String)
807      */

808     public synchronized byte getByte(String JavaDoc parameterName) throws SQLException JavaDoc {
809         ResultSet rs = getOutputParameters(0); // definitely not going to be
810
// from ?=
811

812         byte retValue = rs.getByte(fixParameterName(parameterName));
813
814         this.outputParamWasNull = rs.wasNull();
815
816         return retValue;
817     }
818
819     /**
820      * @see java.sql.CallableStatement#getBytes(int)
821      */

822     public synchronized byte[] getBytes(int parameterIndex) throws SQLException JavaDoc {
823         ResultSet rs = getOutputParameters(parameterIndex);
824
825         byte[] retValue = rs
826                 .getBytes(mapOutputParameterIndexToRsIndex(parameterIndex));
827
828         this.outputParamWasNull = rs.wasNull();
829
830         return retValue;
831     }
832
833     /**
834      * @see java.sql.CallableStatement#getBytes(java.lang.String)
835      */

836     public synchronized byte[] getBytes(String JavaDoc parameterName)
837             throws SQLException JavaDoc {
838         ResultSet rs = getOutputParameters(0); // definitely not going to be
839
// from ?=
840

841         byte[] retValue = rs.getBytes(fixParameterName(parameterName));
842
843         this.outputParamWasNull = rs.wasNull();
844
845         return retValue;
846     }
847
848     /**
849      * @see java.sql.CallableStatement#getClob(int)
850      */

851     public synchronized Clob getClob(int parameterIndex) throws SQLException JavaDoc {
852         ResultSet rs = getOutputParameters(parameterIndex);
853
854         Clob retValue = rs
855                 .getClob(mapOutputParameterIndexToRsIndex(parameterIndex));
856
857         this.outputParamWasNull = rs.wasNull();
858
859         return retValue;
860     }
861
862     /**
863      * @see java.sql.CallableStatement#getClob(java.lang.String)
864      */

865     public synchronized Clob getClob(String