source: Ballon/out/artifacts/geisa_artifact/WEB-INF/lib/mysql-connector-java-5.1.21/src/com/mysql/jdbc/jdbc2/optional/PreparedStatementWrapper.java @ 848

Last change on this file since 848 was 766, checked in by npipsl, 11 years ago
File size: 33.9 KB
Line 
1/*
2 Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3 
4
5  The MySQL Connector/J is licensed under the terms of the GPLv2
6  <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most MySQL Connectors.
7  There are special exceptions to the terms and conditions of the GPLv2 as it is applied to
8  this software, see the FLOSS License Exception
9  <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
10
11  This program is free software; you can redistribute it and/or modify it under the terms
12  of the GNU General Public License as published by the Free Software Foundation; version 2
13  of the License.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
16  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  See the GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License along with this
20  program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth
21  Floor, Boston, MA 02110-1301  USA
22
23
24
25 */
26package com.mysql.jdbc.jdbc2.optional;
27
28import java.io.InputStream;
29import java.io.Reader;
30import java.lang.reflect.Constructor;
31import java.math.BigDecimal;
32import java.net.URL;
33import java.sql.Array;
34import java.sql.Blob;
35import java.sql.Clob;
36import java.sql.Date;
37import java.sql.ParameterMetaData;
38import java.sql.PreparedStatement;
39import java.sql.Ref;
40import java.sql.ResultSet;
41import java.sql.ResultSetMetaData;
42import java.sql.SQLException;
43import java.sql.Time;
44import java.sql.Timestamp;
45import java.util.Calendar;
46
47import com.mysql.jdbc.SQLError;
48import com.mysql.jdbc.Util;
49
50/**
51 * Wraps prepared statements so that errors can be reported correctly to
52 * ConnectionEventListeners.
53 *
54 * @author Mark Matthews
55 *
56 * @version $Id: PreparedStatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38
57 *          mmatthews Exp $
58 */
59public class PreparedStatementWrapper extends StatementWrapper implements
60                PreparedStatement {
61        private static final Constructor<?> JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR;
62       
63        static {
64                if (Util.isJdbc4()) {
65                        try {
66                                JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR = Class.forName(
67                                                "com.mysql.jdbc.jdbc2.optional.JDBC4PreparedStatementWrapper").getConstructor(
68                                                new Class[] { ConnectionWrapper.class, 
69                                                                MysqlPooledConnection.class, 
70                                                                PreparedStatement.class });
71                        } catch (SecurityException e) {
72                                throw new RuntimeException(e);
73                        } catch (NoSuchMethodException e) {
74                                throw new RuntimeException(e);
75                        } catch (ClassNotFoundException e) {
76                                throw new RuntimeException(e);
77                        }
78                } else {
79                        JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR = null;
80                }
81        }
82       
83        protected static PreparedStatementWrapper getInstance(ConnectionWrapper c, 
84                        MysqlPooledConnection conn,
85                        PreparedStatement toWrap) throws SQLException {
86                if (!Util.isJdbc4()) {
87                        return new PreparedStatementWrapper(c, 
88                                        conn, toWrap);
89                }
90
91                return (PreparedStatementWrapper) Util.handleNewInstance(
92                                JDBC_4_PREPARED_STATEMENT_WRAPPER_CTOR,
93                                new Object[] {c, 
94                                                conn, toWrap }, conn.getExceptionInterceptor());
95        }
96       
97        PreparedStatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn,
98                        PreparedStatement toWrap) {
99                super(c, conn, toWrap);
100        }
101
102        /*
103         * (non-Javadoc)
104         *
105         * @see java.sql.PreparedStatement#setArray(int, java.sql.Array)
106         */
107        public void setArray(int parameterIndex, Array x) throws SQLException {
108                try {
109                        if (this.wrappedStmt != null) {
110                                ((PreparedStatement) this.wrappedStmt).setArray(parameterIndex,
111                                                x);
112                        } else {
113                                throw SQLError.createSQLException(
114                                                "No operations allowed after statement closed",
115                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
116                        }
117                } catch (SQLException sqlEx) {
118                        checkAndFireConnectionError(sqlEx);
119                }
120        }
121
122        /*
123         * (non-Javadoc)
124         *
125         * @see java.sql.PreparedStatement#setAsciiStream(int, java.io.InputStream,
126         *      int)
127         */
128        public void setAsciiStream(int parameterIndex, InputStream x, int length)
129                        throws SQLException {
130                try {
131                        if (this.wrappedStmt != null) {
132                                ((PreparedStatement) this.wrappedStmt).setAsciiStream(
133                                                parameterIndex, x, length);
134                        } else {
135                                throw SQLError.createSQLException(
136                                                "No operations allowed after statement closed",
137                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
138                        }
139                } catch (SQLException sqlEx) {
140                        checkAndFireConnectionError(sqlEx);
141                }
142        }
143
144        /*
145         * (non-Javadoc)
146         *
147         * @see java.sql.PreparedStatement#setBigDecimal(int, java.math.BigDecimal)
148         */
149        public void setBigDecimal(int parameterIndex, BigDecimal x)
150                        throws SQLException {
151                try {
152                        if (this.wrappedStmt != null) {
153                                ((PreparedStatement) this.wrappedStmt).setBigDecimal(
154                                                parameterIndex, x);
155                        } else {
156                                throw SQLError.createSQLException(
157                                                "No operations allowed after statement closed",
158                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
159                        }
160                } catch (SQLException sqlEx) {
161                        checkAndFireConnectionError(sqlEx);
162                }
163        }
164
165        /*
166         * (non-Javadoc)
167         *
168         * @see java.sql.PreparedStatement#setBinaryStream(int, java.io.InputStream,
169         *      int)
170         */
171        public void setBinaryStream(int parameterIndex, InputStream x, int length)
172                        throws SQLException {
173                try {
174                        if (this.wrappedStmt != null) {
175                                ((PreparedStatement) this.wrappedStmt).setBinaryStream(
176                                                parameterIndex, x, length);
177                        } else {
178                                throw SQLError.createSQLException(
179                                                "No operations allowed after statement closed",
180                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
181                        }
182                } catch (SQLException sqlEx) {
183                        checkAndFireConnectionError(sqlEx);
184                }
185        }
186
187        /*
188         * (non-Javadoc)
189         *
190         * @see java.sql.PreparedStatement#setBlob(int, java.sql.Blob)
191         */
192        public void setBlob(int parameterIndex, Blob x) throws SQLException {
193                try {
194                        if (this.wrappedStmt != null) {
195                                ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
196                                                x);
197                        } else {
198                                throw SQLError.createSQLException(
199                                                "No operations allowed after statement closed",
200                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
201                        }
202                } catch (SQLException sqlEx) {
203                        checkAndFireConnectionError(sqlEx);
204                }
205        }
206
207        /*
208         * (non-Javadoc)
209         *
210         * @see java.sql.PreparedStatement#setBoolean(int, boolean)
211         */
212        public void setBoolean(int parameterIndex, boolean x) throws SQLException {
213                try {
214                        if (this.wrappedStmt != null) {
215                                ((PreparedStatement) this.wrappedStmt).setBoolean(
216                                                parameterIndex, x);
217                        } else {
218                                throw SQLError.createSQLException(
219                                                "No operations allowed after statement closed",
220                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
221                        }
222                } catch (SQLException sqlEx) {
223                        checkAndFireConnectionError(sqlEx);
224                }
225        }
226
227        /*
228         * (non-Javadoc)
229         *
230         * @see java.sql.PreparedStatement#setByte(int, byte)
231         */
232        public void setByte(int parameterIndex, byte x) throws SQLException {
233                try {
234                        if (this.wrappedStmt != null) {
235                                ((PreparedStatement) this.wrappedStmt).setByte(parameterIndex,
236                                                x);
237                        } else {
238                                throw SQLError.createSQLException(
239                                                "No operations allowed after statement closed",
240                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
241                        }
242                } catch (SQLException sqlEx) {
243                        checkAndFireConnectionError(sqlEx);
244                }
245        }
246
247        /*
248         * (non-Javadoc)
249         *
250         * @see java.sql.PreparedStatement#setBytes(int, byte[])
251         */
252        public void setBytes(int parameterIndex, byte[] x) throws SQLException {
253                try {
254                        if (this.wrappedStmt != null) {
255                                ((PreparedStatement) this.wrappedStmt).setBytes(parameterIndex,
256                                                x);
257                        } else {
258                                throw SQLError.createSQLException(
259                                                "No operations allowed after statement closed",
260                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
261                        }
262                } catch (SQLException sqlEx) {
263                        checkAndFireConnectionError(sqlEx);
264                }
265        }
266
267        /*
268         * (non-Javadoc)
269         *
270         * @see java.sql.PreparedStatement#setCharacterStream(int, java.io.Reader,
271         *      int)
272         */
273        public void setCharacterStream(int parameterIndex, Reader reader, int length)
274                        throws SQLException {
275                try {
276                        if (this.wrappedStmt != null) {
277                                ((PreparedStatement) this.wrappedStmt).setCharacterStream(
278                                                parameterIndex, reader, length);
279                        } else {
280                                throw SQLError.createSQLException(
281                                                "No operations allowed after statement closed",
282                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
283                        }
284                } catch (SQLException sqlEx) {
285                        checkAndFireConnectionError(sqlEx);
286                }
287        }
288
289        /*
290         * (non-Javadoc)
291         *
292         * @see java.sql.PreparedStatement#setClob(int, java.sql.Clob)
293         */
294        public void setClob(int parameterIndex, Clob x) throws SQLException {
295                try {
296                        if (this.wrappedStmt != null) {
297                                ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
298                                                x);
299                        } else {
300                                throw SQLError.createSQLException(
301                                                "No operations allowed after statement closed",
302                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
303                        }
304                } catch (SQLException sqlEx) {
305                        checkAndFireConnectionError(sqlEx);
306                }
307        }
308
309        /*
310         * (non-Javadoc)
311         *
312         * @see java.sql.PreparedStatement#setDate(int, java.sql.Date)
313         */
314        public void setDate(int parameterIndex, Date x) throws SQLException {
315                try {
316                        if (this.wrappedStmt != null) {
317                                ((PreparedStatement) this.wrappedStmt).setDate(parameterIndex,
318                                                x);
319                        } else {
320                                throw SQLError.createSQLException(
321                                                "No operations allowed after statement closed",
322                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
323                        }
324                } catch (SQLException sqlEx) {
325                        checkAndFireConnectionError(sqlEx);
326                }
327        }
328
329        /*
330         * (non-Javadoc)
331         *
332         * @see java.sql.PreparedStatement#setDate(int, java.sql.Date,
333         *      java.util.Calendar)
334         */
335        public void setDate(int parameterIndex, Date x, Calendar cal)
336                        throws SQLException {
337                try {
338                        if (this.wrappedStmt != null) {
339                                ((PreparedStatement) this.wrappedStmt).setDate(parameterIndex,
340                                                x, cal);
341                        } else {
342                                throw SQLError.createSQLException(
343                                                "No operations allowed after statement closed",
344                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
345                        }
346                } catch (SQLException sqlEx) {
347                        checkAndFireConnectionError(sqlEx);
348                }
349        }
350
351        /*
352         * (non-Javadoc)
353         *
354         * @see java.sql.PreparedStatement#setDouble(int, double)
355         */
356        public void setDouble(int parameterIndex, double x) throws SQLException {
357                try {
358                        if (this.wrappedStmt != null) {
359                                ((PreparedStatement) this.wrappedStmt).setDouble(
360                                                parameterIndex, x);
361                        } else {
362                                throw SQLError.createSQLException(
363                                                "No operations allowed after statement closed",
364                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
365                        }
366                } catch (SQLException sqlEx) {
367                        checkAndFireConnectionError(sqlEx);
368                }
369        }
370
371        /*
372         * (non-Javadoc)
373         *
374         * @see java.sql.PreparedStatement#setFloat(int, float)
375         */
376        public void setFloat(int parameterIndex, float x) throws SQLException {
377                try {
378                        if (this.wrappedStmt != null) {
379                                ((PreparedStatement) this.wrappedStmt).setFloat(parameterIndex,
380                                                x);
381                        } else {
382                                throw SQLError.createSQLException(
383                                                "No operations allowed after statement closed",
384                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
385                        }
386                } catch (SQLException sqlEx) {
387                        checkAndFireConnectionError(sqlEx);
388                }
389        }
390
391        /*
392         * (non-Javadoc)
393         *
394         * @see java.sql.PreparedStatement#setInt(int, int)
395         */
396        public void setInt(int parameterIndex, int x) throws SQLException {
397                try {
398                        if (this.wrappedStmt != null) {
399                                ((PreparedStatement) this.wrappedStmt)
400                                                .setInt(parameterIndex, x);
401                        } else {
402                                throw SQLError.createSQLException(
403                                                "No operations allowed after statement closed",
404                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
405                        }
406                } catch (SQLException sqlEx) {
407                        checkAndFireConnectionError(sqlEx);
408                }
409        }
410
411        /*
412         * (non-Javadoc)
413         *
414         * @see java.sql.PreparedStatement#setLong(int, long)
415         */
416        public void setLong(int parameterIndex, long x) throws SQLException {
417                try {
418                        if (this.wrappedStmt != null) {
419                                ((PreparedStatement) this.wrappedStmt).setLong(parameterIndex,
420                                                x);
421                        } else {
422                                throw SQLError.createSQLException(
423                                                "No operations allowed after statement closed",
424                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
425                        }
426                } catch (SQLException sqlEx) {
427                        checkAndFireConnectionError(sqlEx);
428                }
429        }
430
431        /*
432         * (non-Javadoc)
433         *
434         * @see java.sql.PreparedStatement#getMetaData()
435         */
436        public ResultSetMetaData getMetaData() throws SQLException {
437                try {
438                        if (this.wrappedStmt != null) {
439                                return ((PreparedStatement) this.wrappedStmt).getMetaData();
440                        }
441
442                        throw SQLError.createSQLException(
443                                        "No operations allowed after statement closed",
444                                        SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
445                } catch (SQLException sqlEx) {
446                        checkAndFireConnectionError(sqlEx);
447                }
448
449                return null;
450        }
451
452        /*
453         * (non-Javadoc)
454         *
455         * @see java.sql.PreparedStatement#setNull(int, int)
456         */
457        public void setNull(int parameterIndex, int sqlType) throws SQLException {
458                try {
459                        if (this.wrappedStmt != null) {
460                                ((PreparedStatement) this.wrappedStmt).setNull(parameterIndex,
461                                                sqlType);
462                        } else {
463                                throw SQLError.createSQLException(
464                                                "No operations allowed after statement closed",
465                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
466                        }
467                } catch (SQLException sqlEx) {
468                        checkAndFireConnectionError(sqlEx);
469                }
470        }
471
472        /*
473         * (non-Javadoc)
474         *
475         * @see java.sql.PreparedStatement#setNull(int, int, java.lang.String)
476         */
477        public void setNull(int parameterIndex, int sqlType, String typeName)
478                        throws SQLException {
479                try {
480                        if (this.wrappedStmt != null) {
481                                ((PreparedStatement) this.wrappedStmt).setNull(parameterIndex,
482                                                sqlType, typeName);
483                        } else {
484                                throw SQLError.createSQLException(
485                                                "No operations allowed after statement closed",
486                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
487                        }
488                } catch (SQLException sqlEx) {
489                        checkAndFireConnectionError(sqlEx);
490                }
491        }
492
493        /*
494         * (non-Javadoc)
495         *
496         * @see java.sql.PreparedStatement#setObject(int, java.lang.Object)
497         */
498        public void setObject(int parameterIndex, Object x) throws SQLException {
499                try {
500                        if (this.wrappedStmt != null) {
501                                ((PreparedStatement) this.wrappedStmt).setObject(
502                                                parameterIndex, x);
503                        } else {
504                                throw SQLError.createSQLException(
505                                                "No operations allowed after statement closed",
506                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
507                        }
508                } catch (SQLException sqlEx) {
509                        checkAndFireConnectionError(sqlEx);
510                }
511        }
512
513        /*
514         * (non-Javadoc)
515         *
516         * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int)
517         */
518        public void setObject(int parameterIndex, Object x, int targetSqlType)
519                        throws SQLException {
520                try {
521                        if (this.wrappedStmt != null) {
522                                ((PreparedStatement) this.wrappedStmt).setObject(
523                                                parameterIndex, x, targetSqlType);
524                        } else {
525                                throw SQLError.createSQLException(
526                                                "No operations allowed after statement closed",
527                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
528                        }
529                } catch (SQLException sqlEx) {
530                        checkAndFireConnectionError(sqlEx);
531                }
532        }
533
534        /*
535         * (non-Javadoc)
536         *
537         * @see java.sql.PreparedStatement#setObject(int, java.lang.Object, int,
538         *      int)
539         */
540        public void setObject(int parameterIndex, Object x, int targetSqlType,
541                        int scale) throws SQLException {
542                try {
543                        if (this.wrappedStmt != null) {
544                                ((PreparedStatement) this.wrappedStmt).setObject(
545                                                parameterIndex, x, targetSqlType, scale);
546                        } else {
547                                throw SQLError.createSQLException(
548                                                "No operations allowed after statement closed",
549                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
550                        }
551                } catch (SQLException sqlEx) {
552                        checkAndFireConnectionError(sqlEx);
553                }
554        }
555
556        /*
557         * (non-Javadoc)
558         *
559         * @see java.sql.PreparedStatement#getParameterMetaData()
560         */
561        public ParameterMetaData getParameterMetaData() throws SQLException {
562                try {
563                        if (this.wrappedStmt != null) {
564                                return ((PreparedStatement) this.wrappedStmt)
565                                                .getParameterMetaData();
566                        }
567
568                        throw SQLError.createSQLException(
569                                        "No operations allowed after statement closed",
570                                        SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
571                } catch (SQLException sqlEx) {
572                        checkAndFireConnectionError(sqlEx);
573                }
574
575                return null;
576        }
577
578        /*
579         * (non-Javadoc)
580         *
581         * @see java.sql.PreparedStatement#setRef(int, java.sql.Ref)
582         */
583        public void setRef(int parameterIndex, Ref x) throws SQLException {
584                try {
585                        if (this.wrappedStmt != null) {
586                                ((PreparedStatement) this.wrappedStmt)
587                                                .setRef(parameterIndex, x);
588                        } else {
589                                throw SQLError.createSQLException(
590                                                "No operations allowed after statement closed",
591                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
592                        }
593                } catch (SQLException sqlEx) {
594                        checkAndFireConnectionError(sqlEx);
595                }
596        }
597
598        /*
599         * (non-Javadoc)
600         *
601         * @see java.sql.PreparedStatement#setShort(int, short)
602         */
603        public void setShort(int parameterIndex, short x) throws SQLException {
604                try {
605                        if (this.wrappedStmt != null) {
606                                ((PreparedStatement) this.wrappedStmt).setShort(parameterIndex,
607                                                x);
608                        } else {
609                                throw SQLError.createSQLException(
610                                                "No operations allowed after statement closed",
611                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
612                        }
613                } catch (SQLException sqlEx) {
614                        checkAndFireConnectionError(sqlEx);
615                }
616        }
617
618        /*
619         * (non-Javadoc)
620         *
621         * @see java.sql.PreparedStatement#setString(int, java.lang.String)
622         */
623        public void setString(int parameterIndex, String x) throws SQLException {
624                try {
625                        if (this.wrappedStmt != null) {
626                                ((PreparedStatement) this.wrappedStmt).setString(
627                                                parameterIndex, x);
628                        } else {
629                                throw SQLError.createSQLException(
630                                                "No operations allowed after statement closed",
631                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
632                        }
633                } catch (SQLException sqlEx) {
634                        checkAndFireConnectionError(sqlEx);
635                }
636        }
637
638        /*
639         * (non-Javadoc)
640         *
641         * @see java.sql.PreparedStatement#setTime(int, java.sql.Time)
642         */
643        public void setTime(int parameterIndex, Time x) throws SQLException {
644                try {
645                        if (this.wrappedStmt != null) {
646                                ((PreparedStatement) this.wrappedStmt).setTime(parameterIndex,
647                                                x);
648                        } else {
649                                throw SQLError.createSQLException(
650                                                "No operations allowed after statement closed",
651                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
652                        }
653                } catch (SQLException sqlEx) {
654                        checkAndFireConnectionError(sqlEx);
655                }
656        }
657
658        /*
659         * (non-Javadoc)
660         *
661         * @see java.sql.PreparedStatement#setTime(int, java.sql.Time,
662         *      java.util.Calendar)
663         */
664        public void setTime(int parameterIndex, Time x, Calendar cal)
665                        throws SQLException {
666                try {
667                        if (this.wrappedStmt != null) {
668                                ((PreparedStatement) this.wrappedStmt).setTime(parameterIndex,
669                                                x, cal);
670                        } else {
671                                throw SQLError.createSQLException(
672                                                "No operations allowed after statement closed",
673                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
674                        }
675                } catch (SQLException sqlEx) {
676                        checkAndFireConnectionError(sqlEx);
677                }
678        }
679
680        /*
681         * (non-Javadoc)
682         *
683         * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp)
684         */
685        public void setTimestamp(int parameterIndex, Timestamp x)
686                        throws SQLException {
687                try {
688                        if (this.wrappedStmt != null) {
689                                ((PreparedStatement) this.wrappedStmt).setTimestamp(
690                                                parameterIndex, x);
691                        } else {
692                                throw SQLError.createSQLException(
693                                                "No operations allowed after statement closed",
694                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
695                        }
696                } catch (SQLException sqlEx) {
697                        checkAndFireConnectionError(sqlEx);
698                }
699        }
700
701        /*
702         * (non-Javadoc)
703         *
704         * @see java.sql.PreparedStatement#setTimestamp(int, java.sql.Timestamp,
705         *      java.util.Calendar)
706         */
707        public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal)
708                        throws SQLException {
709                try {
710                        if (this.wrappedStmt != null) {
711                                ((PreparedStatement) this.wrappedStmt).setTimestamp(
712                                                parameterIndex, x, cal);
713                        } else {
714                                throw SQLError.createSQLException(
715                                                "No operations allowed after statement closed",
716                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
717                        }
718                } catch (SQLException sqlEx) {
719                        checkAndFireConnectionError(sqlEx);
720                }
721        }
722
723        /*
724         * (non-Javadoc)
725         *
726         * @see java.sql.PreparedStatement#setURL(int, java.net.URL)
727         */
728        public void setURL(int parameterIndex, URL x) throws SQLException {
729                try {
730                        if (this.wrappedStmt != null) {
731                                ((PreparedStatement) this.wrappedStmt)
732                                                .setURL(parameterIndex, x);
733                        } else {
734                                throw SQLError.createSQLException(
735                                                "No operations allowed after statement closed",
736                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
737                        }
738                } catch (SQLException sqlEx) {
739                        checkAndFireConnectionError(sqlEx);
740                }
741        }
742
743        /**
744         * DOCUMENT ME!
745         *
746         * @param parameterIndex
747         *            DOCUMENT ME!
748         * @param x
749         *            DOCUMENT ME!
750         * @param length
751         *            DOCUMENT ME!
752         *
753         * @throws SQLException
754         *             DOCUMENT ME!
755         *
756         * @see java.sql.PreparedStatement#setUnicodeStream(int,
757         *      java.io.InputStream, int)
758         * @deprecated
759         */
760        public void setUnicodeStream(int parameterIndex, InputStream x, int length)
761                        throws SQLException {
762                try {
763                        if (this.wrappedStmt != null) {
764                                ((PreparedStatement) this.wrappedStmt).setUnicodeStream(
765                                                parameterIndex, x, length);
766                        } else {
767                                throw SQLError.createSQLException(
768                                                "No operations allowed after statement closed",
769                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
770                        }
771                } catch (SQLException sqlEx) {
772                        checkAndFireConnectionError(sqlEx);
773                }
774        }
775
776        /*
777         * (non-Javadoc)
778         *
779         * @see java.sql.PreparedStatement#addBatch()
780         */
781        public void addBatch() throws SQLException {
782                try {
783                        if (this.wrappedStmt != null) {
784                                ((PreparedStatement) this.wrappedStmt).addBatch();
785                        } else {
786                                throw SQLError.createSQLException(
787                                                "No operations allowed after statement closed",
788                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
789                        }
790                } catch (SQLException sqlEx) {
791                        checkAndFireConnectionError(sqlEx);
792                }
793        }
794
795        /*
796         * (non-Javadoc)
797         *
798         * @see java.sql.PreparedStatement#clearParameters()
799         */
800        public void clearParameters() throws SQLException {
801                try {
802                        if (this.wrappedStmt != null) {
803                                ((PreparedStatement) this.wrappedStmt).clearParameters();
804                        } else {
805                                throw SQLError.createSQLException(
806                                                "No operations allowed after statement closed",
807                                                SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
808                        }
809                } catch (SQLException sqlEx) {
810                        checkAndFireConnectionError(sqlEx);
811                }
812        }
813
814        /*
815         * (non-Javadoc)
816         *
817         * @see java.sql.PreparedStatement#execute()
818         */
819        public boolean execute() throws SQLException {
820                try {
821                        if (this.wrappedStmt != null) {
822                                return ((PreparedStatement) this.wrappedStmt).execute();
823                        }
824
825                        throw SQLError.createSQLException(
826                                        "No operations allowed after statement closed",
827                                        SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
828                } catch (SQLException sqlEx) {
829                        checkAndFireConnectionError(sqlEx);
830                }
831
832                return false; // we actually never get here, but the compiler can't
833                // figure
834
835                // that out
836        }
837
838        /*
839         * (non-Javadoc)
840         *
841         * @see java.sql.PreparedStatement#executeQuery()
842         */
843        public ResultSet executeQuery() throws SQLException {
844                try {
845                        if (this.wrappedStmt != null) {
846                                ResultSet rs = ((PreparedStatement) this.wrappedStmt)
847                                                .executeQuery();
848
849                                ((com.mysql.jdbc.ResultSetInternalMethods) rs).setWrapperStatement(this);
850
851                                return rs;
852                        }
853
854                        throw SQLError.createSQLException(
855                                        "No operations allowed after statement closed",
856                                        SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
857                } catch (SQLException sqlEx) {
858                        checkAndFireConnectionError(sqlEx);
859                }
860
861                return null; // we actually never get here, but the compiler can't
862                // figure
863
864                // that out
865        }
866
867        /*
868         * (non-Javadoc)
869         *
870         * @see java.sql.PreparedStatement#executeUpdate()
871         */
872        public int executeUpdate() throws SQLException {
873                try {
874                        if (this.wrappedStmt != null) {
875                                return ((PreparedStatement) this.wrappedStmt).executeUpdate();
876                        }
877
878                        throw SQLError.createSQLException(
879                                        "No operations allowed after statement closed",
880                                        SQLError.SQL_STATE_GENERAL_ERROR, this.exceptionInterceptor);
881                } catch (SQLException sqlEx) {
882                        checkAndFireConnectionError(sqlEx);
883                }
884
885                return -1; // we actually never get here, but the compiler can't figure
886
887                // that out
888        }
889//
890//      public void setAsciiStream(int parameterIndex, InputStream x)
891//                      throws SQLException {
892//              try {
893//                      if (this.wrappedStmt != null) {
894//                              ((PreparedStatement) this.wrappedStmt).setAsciiStream(
895//                                              parameterIndex, x);
896//                      } else {
897//                              throw SQLError.createSQLException(
898//                                              "No operations allowed after statement closed",
899//                                              SQLError.SQL_STATE_GENERAL_ERROR);
900//                      }
901//              } catch (SQLException sqlEx) {
902//                      checkAndFireConnectionError(sqlEx);
903//              }
904//      }
905//
906//      public void setAsciiStream(int parameterIndex, InputStream x, long length)
907//                      throws SQLException {
908//              try {
909//                      if (this.wrappedStmt != null) {
910//                              ((PreparedStatement) this.wrappedStmt).setAsciiStream(
911//                                              parameterIndex, x, length);
912//                      } else {
913//                              throw SQLError.createSQLException(
914//                                              "No operations allowed after statement closed",
915//                                              SQLError.SQL_STATE_GENERAL_ERROR);
916//                      }
917//              } catch (SQLException sqlEx) {
918//                      checkAndFireConnectionError(sqlEx);
919//              }
920//      }
921//
922//      public void setBinaryStream(int parameterIndex, InputStream x)
923//                      throws SQLException {
924//              try {
925//                      if (this.wrappedStmt != null) {
926//                              ((PreparedStatement) this.wrappedStmt).setBinaryStream(
927//                                              parameterIndex, x);
928//                      } else {
929//                              throw SQLError.createSQLException(
930//                                              "No operations allowed after statement closed",
931//                                              SQLError.SQL_STATE_GENERAL_ERROR);
932//                      }
933//              } catch (SQLException sqlEx) {
934//                      checkAndFireConnectionError(sqlEx);
935//              }
936//      }
937//
938//      public void setBinaryStream(int parameterIndex, InputStream x, long length)
939//                      throws SQLException {
940//              try {
941//                      if (this.wrappedStmt != null) {
942//                              ((PreparedStatement) this.wrappedStmt).setBinaryStream(
943//                                              parameterIndex, x, length);
944//                      } else {
945//                              throw SQLError.createSQLException(
946//                                              "No operations allowed after statement closed",
947//                                              SQLError.SQL_STATE_GENERAL_ERROR);
948//                      }
949//              } catch (SQLException sqlEx) {
950//                      checkAndFireConnectionError(sqlEx);
951//              }
952//      }
953//
954//      public void setBlob(int parameterIndex, InputStream inputStream)
955//                      throws SQLException {
956//              try {
957//                      if (this.wrappedStmt != null) {
958//                              ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
959//                                              inputStream);
960//                      } else {
961//                              throw SQLError.createSQLException(
962//                                              "No operations allowed after statement closed",
963//                                              SQLError.SQL_STATE_GENERAL_ERROR);
964//                      }
965//              } catch (SQLException sqlEx) {
966//                      checkAndFireConnectionError(sqlEx);
967//              }
968//      }
969//
970//      public void setBlob(int parameterIndex, InputStream inputStream, long length)
971//                      throws SQLException {
972//              try {
973//                      if (this.wrappedStmt != null) {
974//                              ((PreparedStatement) this.wrappedStmt).setBlob(parameterIndex,
975//                                              inputStream, length);
976//                      } else {
977//                              throw SQLError.createSQLException(
978//                                              "No operations allowed after statement closed",
979//                                              SQLError.SQL_STATE_GENERAL_ERROR);
980//                      }
981//              } catch (SQLException sqlEx) {
982//                      checkAndFireConnectionError(sqlEx);
983//              }
984//      }
985//
986//      public void setCharacterStream(int parameterIndex, Reader reader)
987//                      throws SQLException {
988//              try {
989//                      if (this.wrappedStmt != null) {
990//                              ((PreparedStatement) this.wrappedStmt).setCharacterStream(
991//                                              parameterIndex, reader);
992//                      } else {
993//                              throw SQLError.createSQLException(
994//                                              "No operations allowed after statement closed",
995//                                              SQLError.SQL_STATE_GENERAL_ERROR);
996//                      }
997//              } catch (SQLException sqlEx) {
998//                      checkAndFireConnectionError(sqlEx);
999//              }
1000//      }
1001//
1002//      public void setCharacterStream(int parameterIndex, Reader reader,
1003//                      long length) throws SQLException {
1004//              try {
1005//                      if (this.wrappedStmt != null) {
1006//                              ((PreparedStatement) this.wrappedStmt).setCharacterStream(
1007//                                              parameterIndex, reader, length);
1008//                      } else {
1009//                              throw SQLError.createSQLException(
1010//                                              "No operations allowed after statement closed",
1011//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1012//                      }
1013//              } catch (SQLException sqlEx) {
1014//                      checkAndFireConnectionError(sqlEx);
1015//              }
1016//      }
1017//
1018//      public void setClob(int parameterIndex, Reader reader) throws SQLException {
1019//              try {
1020//                      if (this.wrappedStmt != null) {
1021//                              ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
1022//                                              reader);
1023//                      } else {
1024//                              throw SQLError.createSQLException(
1025//                                              "No operations allowed after statement closed",
1026//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1027//                      }
1028//              } catch (SQLException sqlEx) {
1029//                      checkAndFireConnectionError(sqlEx);
1030//              }
1031//      }
1032//
1033//      public void setClob(int parameterIndex, Reader reader, long length)
1034//                      throws SQLException {
1035//              try {
1036//                      if (this.wrappedStmt != null) {
1037//                              ((PreparedStatement) this.wrappedStmt).setClob(parameterIndex,
1038//                                              reader, length);
1039//                      } else {
1040//                              throw SQLError.createSQLException(
1041//                                              "No operations allowed after statement closed",
1042//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1043//                      }
1044//              } catch (SQLException sqlEx) {
1045//                      checkAndFireConnectionError(sqlEx);
1046//              }
1047//      }
1048//
1049//      public void setNCharacterStream(int parameterIndex, Reader value)
1050//                      throws SQLException {
1051//              try {
1052//                      if (this.wrappedStmt != null) {
1053//                              ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
1054//                                              parameterIndex, value);
1055//                      } else {
1056//                              throw SQLError.createSQLException(
1057//                                              "No operations allowed after statement closed",
1058//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1059//                      }
1060//              } catch (SQLException sqlEx) {
1061//                      checkAndFireConnectionError(sqlEx);
1062//              }
1063//      }
1064//
1065//      public void setNCharacterStream(int parameterIndex, Reader value,
1066//                      long length) throws SQLException {
1067//              try {
1068//                      if (this.wrappedStmt != null) {
1069//                              ((PreparedStatement) this.wrappedStmt).setNCharacterStream(
1070//                                              parameterIndex, value, length);
1071//                      } else {
1072//                              throw SQLError.createSQLException(
1073//                                              "No operations allowed after statement closed",
1074//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1075//                      }
1076//              } catch (SQLException sqlEx) {
1077//                      checkAndFireConnectionError(sqlEx);
1078//              }
1079//      }
1080//
1081//      public void setNClob(int parameterIndex, NClob value) throws SQLException {
1082//              try {
1083//                      if (this.wrappedStmt != null) {
1084//                              ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1085//                                              value);
1086//                      } else {
1087//                              throw SQLError.createSQLException(
1088//                                              "No operations allowed after statement closed",
1089//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1090//                      }
1091//              } catch (SQLException sqlEx) {
1092//                      checkAndFireConnectionError(sqlEx);
1093//              }
1094//      }
1095//
1096//      public void setNClob(int parameterIndex, Reader reader) throws SQLException {
1097//              try {
1098//                      if (this.wrappedStmt != null) {
1099//                              ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1100//                                              reader);
1101//                      } else {
1102//                              throw SQLError.createSQLException(
1103//                                              "No operations allowed after statement closed",
1104//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1105//                      }
1106//              } catch (SQLException sqlEx) {
1107//                      checkAndFireConnectionError(sqlEx);
1108//              }
1109//      }
1110//
1111//      public void setNClob(int parameterIndex, Reader reader, long length)
1112//                      throws SQLException {
1113//              try {
1114//                      if (this.wrappedStmt != null) {
1115//                              ((PreparedStatement) this.wrappedStmt).setNClob(parameterIndex,
1116//                                              reader, length);
1117//                      } else {
1118//                              throw SQLError.createSQLException(
1119//                                              "No operations allowed after statement closed",
1120//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1121//                      }
1122//              } catch (SQLException sqlEx) {
1123//                      checkAndFireConnectionError(sqlEx);
1124//              }
1125//      }
1126//
1127//      public void setNString(int parameterIndex, String value)
1128//                      throws SQLException {
1129//              try {
1130//                      if (this.wrappedStmt != null) {
1131//                              ((PreparedStatement) this.wrappedStmt).setNString(
1132//                                              parameterIndex, value);
1133//                      } else {
1134//                              throw SQLError.createSQLException(
1135//                                              "No operations allowed after statement closed",
1136//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1137//                      }
1138//              } catch (SQLException sqlEx) {
1139//                      checkAndFireConnectionError(sqlEx);
1140//              }
1141//      }
1142//
1143//      public void setRowId(int parameterIndex, RowId x) throws SQLException {
1144//              try {
1145//                      if (this.wrappedStmt != null) {
1146//                              ((PreparedStatement) this.wrappedStmt).setRowId(parameterIndex,
1147//                                              x);
1148//                      } else {
1149//                              throw SQLError.createSQLException(
1150//                                              "No operations allowed after statement closed",
1151//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1152//                      }
1153//              } catch (SQLException sqlEx) {
1154//                      checkAndFireConnectionError(sqlEx);
1155//              }
1156//      }
1157//
1158//      public void setSQLXML(int parameterIndex, SQLXML xmlObject)
1159//                      throws SQLException {
1160//              try {
1161//                      if (this.wrappedStmt != null) {
1162//                              ((PreparedStatement) this.wrappedStmt).setSQLXML(
1163//                                              parameterIndex, xmlObject);
1164//                      } else {
1165//                              throw SQLError.createSQLException(
1166//                                              "No operations allowed after statement closed",
1167//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1168//                      }
1169//              } catch (SQLException sqlEx) {
1170//                      checkAndFireConnectionError(sqlEx);
1171//              }
1172//      }
1173//
1174//      public boolean isClosed() throws SQLException {
1175//              try {
1176//                      if (this.wrappedStmt != null) {
1177//                              return ((PreparedStatement) this.wrappedStmt).isClosed();
1178//                      } else {
1179//                              throw SQLError.createSQLException(
1180//                                              "No operations allowed after statement closed",
1181//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1182//                      }
1183//              } catch (SQLException sqlEx) {
1184//                      checkAndFireConnectionError(sqlEx);
1185//              }
1186//
1187//              return true;
1188//      }
1189//
1190//      public boolean isPoolable() throws SQLException {
1191//              try {
1192//                      if (this.wrappedStmt != null) {
1193//                              return ((PreparedStatement) this.wrappedStmt).isPoolable();
1194//                      } else {
1195//                              throw SQLError.createSQLException(
1196//                                              "No operations allowed after statement closed",
1197//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1198//                      }
1199//              } catch (SQLException sqlEx) {
1200//                      checkAndFireConnectionError(sqlEx);
1201//              }
1202//
1203//              return false;
1204//      }
1205//
1206//      public void setPoolable(boolean poolable) throws SQLException {
1207//              try {
1208//                      if (this.wrappedStmt != null) {
1209//                              ((PreparedStatement) this.wrappedStmt).setPoolable(poolable);
1210//                      } else {
1211//                              throw SQLError.createSQLException(
1212//                                              "No operations allowed after statement closed",
1213//                                              SQLError.SQL_STATE_GENERAL_ERROR);
1214//                      }
1215//              } catch (SQLException sqlEx) {
1216//                      checkAndFireConnectionError(sqlEx);
1217//              }
1218//      }
1219//
1220//      public boolean isWrapperFor(Class arg0) throws SQLException {
1221//              throw SQLError.notImplemented();
1222//      }
1223//
1224//      public Object unwrap(Class arg0) throws SQLException {
1225//              throw SQLError.notImplemented();
1226//      }
1227}
Note: See TracBrowser for help on using the repository browser.