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.jdbc2.optional; |
26 | |
27 | import com.mysql.jdbc.SQLError; |
28 | |
29 | import java.sql.Connection; |
30 | import java.sql.ResultSet; |
31 | import java.sql.SQLException; |
32 | import java.sql.SQLWarning; |
33 | import java.sql.Statement; |
34 | |
35 | /** |
36 | * Wraps statements so that errors can be reported correctly to |
37 | * ConnectionEventListeners. |
38 | * |
39 | * @author Mark Matthews |
40 | * |
41 | * @version $Id: StatementWrapper.java,v 1.1.2.1 2005/05/13 18:58:38 mmatthews |
42 | * Exp $ |
43 | */ |
44 | public class StatementWrapper extends WrapperBase implements Statement { |
45 | protected Statement wrappedStmt; |
46 | |
47 | protected ConnectionWrapper wrappedConn; |
48 | |
49 | protected StatementWrapper(ConnectionWrapper c, MysqlPooledConnection conn, |
50 | Statement toWrap) { |
51 | this.pooledConnection = conn; |
52 | this.wrappedStmt = toWrap; |
53 | this.wrappedConn = c; |
54 | } |
55 | |
56 | /* |
57 | * (non-Javadoc) |
58 | * |
59 | * @see java.sql.Statement#getConnection() |
60 | */ |
61 | public Connection getConnection() throws SQLException { |
62 | try { |
63 | if (this.wrappedStmt != null) { |
64 | return this.wrappedConn; |
65 | } |
66 | |
67 | throw SQLError.createSQLException("Statement already closed", |
68 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
69 | } catch (SQLException sqlEx) { |
70 | checkAndFireConnectionError(sqlEx); |
71 | } |
72 | |
73 | return null; // we actually never get here, but the compiler can't |
74 | // figure |
75 | |
76 | // that out |
77 | } |
78 | |
79 | /* |
80 | * (non-Javadoc) |
81 | * |
82 | * @see java.sql.Statement#setCursorName(java.lang.String) |
83 | */ |
84 | public void setCursorName(String name) throws SQLException { |
85 | try { |
86 | if (this.wrappedStmt != null) { |
87 | this.wrappedStmt.setCursorName(name); |
88 | } else { |
89 | throw SQLError.createSQLException("Statement already closed", |
90 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
91 | } |
92 | } catch (SQLException sqlEx) { |
93 | checkAndFireConnectionError(sqlEx); |
94 | } |
95 | } |
96 | |
97 | /* |
98 | * (non-Javadoc) |
99 | * |
100 | * @see java.sql.Statement#setEscapeProcessing(boolean) |
101 | */ |
102 | public void setEscapeProcessing(boolean enable) throws SQLException { |
103 | try { |
104 | if (this.wrappedStmt != null) { |
105 | this.wrappedStmt.setEscapeProcessing(enable); |
106 | } else { |
107 | throw SQLError.createSQLException("Statement already closed", |
108 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
109 | } |
110 | } catch (SQLException sqlEx) { |
111 | checkAndFireConnectionError(sqlEx); |
112 | } |
113 | } |
114 | |
115 | /* |
116 | * (non-Javadoc) |
117 | * |
118 | * @see java.sql.Statement#setFetchDirection(int) |
119 | */ |
120 | public void setFetchDirection(int direction) throws SQLException { |
121 | try { |
122 | if (this.wrappedStmt != null) { |
123 | this.wrappedStmt.setFetchDirection(direction); |
124 | } else { |
125 | throw SQLError.createSQLException("Statement already closed", |
126 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
127 | } |
128 | } catch (SQLException sqlEx) { |
129 | checkAndFireConnectionError(sqlEx); |
130 | } |
131 | } |
132 | |
133 | /* |
134 | * (non-Javadoc) |
135 | * |
136 | * @see java.sql.Statement#getFetchDirection() |
137 | */ |
138 | public int getFetchDirection() throws SQLException { |
139 | try { |
140 | if (this.wrappedStmt != null) { |
141 | return this.wrappedStmt.getFetchDirection(); |
142 | } |
143 | |
144 | throw SQLError.createSQLException("Statement already closed", |
145 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
146 | } catch (SQLException sqlEx) { |
147 | checkAndFireConnectionError(sqlEx); |
148 | } |
149 | |
150 | return ResultSet.FETCH_FORWARD; // we actually never get here, but the |
151 | // compiler can't figure |
152 | |
153 | // that out |
154 | } |
155 | |
156 | /* |
157 | * (non-Javadoc) |
158 | * |
159 | * @see java.sql.Statement#setFetchSize(int) |
160 | */ |
161 | public void setFetchSize(int rows) throws SQLException { |
162 | try { |
163 | if (this.wrappedStmt != null) { |
164 | this.wrappedStmt.setFetchSize(rows); |
165 | } else { |
166 | throw SQLError.createSQLException("Statement already closed", |
167 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
168 | } |
169 | } catch (SQLException sqlEx) { |
170 | checkAndFireConnectionError(sqlEx); |
171 | } |
172 | } |
173 | |
174 | /* |
175 | * (non-Javadoc) |
176 | * |
177 | * @see java.sql.Statement#getFetchSize() |
178 | */ |
179 | public int getFetchSize() throws SQLException { |
180 | try { |
181 | if (this.wrappedStmt != null) { |
182 | return this.wrappedStmt.getFetchSize(); |
183 | } |
184 | |
185 | throw SQLError.createSQLException("Statement already closed", |
186 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
187 | } catch (SQLException sqlEx) { |
188 | checkAndFireConnectionError(sqlEx); |
189 | } |
190 | |
191 | return 0; // we actually never get here, but the compiler can't figure |
192 | |
193 | // that out |
194 | } |
195 | |
196 | /* |
197 | * (non-Javadoc) |
198 | * |
199 | * @see java.sql.Statement#getGeneratedKeys() |
200 | */ |
201 | public ResultSet getGeneratedKeys() throws SQLException { |
202 | try { |
203 | if (this.wrappedStmt != null) { |
204 | return this.wrappedStmt.getGeneratedKeys(); |
205 | } |
206 | |
207 | throw SQLError.createSQLException("Statement already closed", |
208 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
209 | } catch (SQLException sqlEx) { |
210 | checkAndFireConnectionError(sqlEx); |
211 | } |
212 | |
213 | return null; // we actually never get here, but the compiler can't |
214 | // figure |
215 | |
216 | // that out |
217 | } |
218 | |
219 | /* |
220 | * (non-Javadoc) |
221 | * |
222 | * @see java.sql.Statement#setMaxFieldSize(int) |
223 | */ |
224 | public void setMaxFieldSize(int max) throws SQLException { |
225 | try { |
226 | if (this.wrappedStmt != null) { |
227 | this.wrappedStmt.setMaxFieldSize(max); |
228 | } else { |
229 | throw SQLError.createSQLException("Statement already closed", |
230 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
231 | } |
232 | } catch (SQLException sqlEx) { |
233 | checkAndFireConnectionError(sqlEx); |
234 | } |
235 | } |
236 | |
237 | /* |
238 | * (non-Javadoc) |
239 | * |
240 | * @see java.sql.Statement#getMaxFieldSize() |
241 | */ |
242 | public int getMaxFieldSize() throws SQLException { |
243 | try { |
244 | if (this.wrappedStmt != null) { |
245 | return this.wrappedStmt.getMaxFieldSize(); |
246 | } |
247 | |
248 | throw SQLError.createSQLException("Statement already closed", |
249 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
250 | } catch (SQLException sqlEx) { |
251 | checkAndFireConnectionError(sqlEx); |
252 | } |
253 | |
254 | return 0; // we actually never get here, but the compiler can't figure |
255 | |
256 | // that out |
257 | } |
258 | |
259 | /* |
260 | * (non-Javadoc) |
261 | * |
262 | * @see java.sql.Statement#setMaxRows(int) |
263 | */ |
264 | public void setMaxRows(int max) throws SQLException { |
265 | try { |
266 | if (this.wrappedStmt != null) { |
267 | this.wrappedStmt.setMaxRows(max); |
268 | } else { |
269 | throw SQLError.createSQLException("Statement already closed", |
270 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
271 | } |
272 | } catch (SQLException sqlEx) { |
273 | checkAndFireConnectionError(sqlEx); |
274 | } |
275 | } |
276 | |
277 | /* |
278 | * (non-Javadoc) |
279 | * |
280 | * @see java.sql.Statement#getMaxRows() |
281 | */ |
282 | public int getMaxRows() throws SQLException { |
283 | try { |
284 | if (this.wrappedStmt != null) { |
285 | return this.wrappedStmt.getMaxRows(); |
286 | } |
287 | |
288 | throw SQLError.createSQLException("Statement already closed", |
289 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
290 | } catch (SQLException sqlEx) { |
291 | checkAndFireConnectionError(sqlEx); |
292 | } |
293 | |
294 | return 0; // we actually never get here, but the compiler can't figure |
295 | |
296 | // that out |
297 | } |
298 | |
299 | /* |
300 | * (non-Javadoc) |
301 | * |
302 | * @see java.sql.Statement#getMoreResults() |
303 | */ |
304 | public boolean getMoreResults() throws SQLException { |
305 | try { |
306 | if (this.wrappedStmt != null) { |
307 | return this.wrappedStmt.getMoreResults(); |
308 | } |
309 | |
310 | throw SQLError.createSQLException("Statement already closed", |
311 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
312 | } catch (SQLException sqlEx) { |
313 | checkAndFireConnectionError(sqlEx); |
314 | } |
315 | |
316 | return false; |
317 | } |
318 | |
319 | /* |
320 | * (non-Javadoc) |
321 | * |
322 | * @see java.sql.Statement#getMoreResults(int) |
323 | */ |
324 | public boolean getMoreResults(int current) throws SQLException { |
325 | try { |
326 | if (this.wrappedStmt != null) { |
327 | return this.wrappedStmt.getMoreResults(current); |
328 | } |
329 | |
330 | throw SQLError.createSQLException("Statement already closed", |
331 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
332 | } catch (SQLException sqlEx) { |
333 | checkAndFireConnectionError(sqlEx); |
334 | } |
335 | |
336 | return false; |
337 | } |
338 | |
339 | /* |
340 | * (non-Javadoc) |
341 | * |
342 | * @see java.sql.Statement#setQueryTimeout(int) |
343 | */ |
344 | public void setQueryTimeout(int seconds) throws SQLException { |
345 | try { |
346 | if (this.wrappedStmt != null) { |
347 | this.wrappedStmt.setQueryTimeout(seconds); |
348 | } else { |
349 | throw SQLError.createSQLException("Statement already closed", |
350 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
351 | } |
352 | } catch (SQLException sqlEx) { |
353 | checkAndFireConnectionError(sqlEx); |
354 | } |
355 | } |
356 | |
357 | /* |
358 | * (non-Javadoc) |
359 | * |
360 | * @see java.sql.Statement#getQueryTimeout() |
361 | */ |
362 | public int getQueryTimeout() throws SQLException { |
363 | try { |
364 | if (this.wrappedStmt != null) { |
365 | return this.wrappedStmt.getQueryTimeout(); |
366 | } |
367 | |
368 | throw SQLError.createSQLException("Statement already closed", |
369 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
370 | } catch (SQLException sqlEx) { |
371 | checkAndFireConnectionError(sqlEx); |
372 | } |
373 | |
374 | return 0; |
375 | } |
376 | |
377 | /* |
378 | * (non-Javadoc) |
379 | * |
380 | * @see java.sql.Statement#getResultSet() |
381 | */ |
382 | public ResultSet getResultSet() throws SQLException { |
383 | try { |
384 | if (this.wrappedStmt != null) { |
385 | ResultSet rs = this.wrappedStmt.getResultSet(); |
386 | |
387 | ((com.mysql.jdbc.ResultSet) rs).setWrapperStatement(this); |
388 | |
389 | return rs; |
390 | } |
391 | |
392 | throw SQLError.createSQLException("Statement already closed", |
393 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
394 | } catch (SQLException sqlEx) { |
395 | checkAndFireConnectionError(sqlEx); |
396 | } |
397 | |
398 | return null; |
399 | } |
400 | |
401 | /* |
402 | * (non-Javadoc) |
403 | * |
404 | * @see java.sql.Statement#getResultSetConcurrency() |
405 | */ |
406 | public int getResultSetConcurrency() throws SQLException { |
407 | try { |
408 | if (this.wrappedStmt != null) { |
409 | return this.wrappedStmt.getResultSetConcurrency(); |
410 | } |
411 | |
412 | throw SQLError.createSQLException("Statement already closed", |
413 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
414 | } catch (SQLException sqlEx) { |
415 | checkAndFireConnectionError(sqlEx); |
416 | } |
417 | |
418 | return 0; |
419 | } |
420 | |
421 | /* |
422 | * (non-Javadoc) |
423 | * |
424 | * @see java.sql.Statement#getResultSetHoldability() |
425 | */ |
426 | public int getResultSetHoldability() throws SQLException { |
427 | try { |
428 | if (this.wrappedStmt != null) { |
429 | return this.wrappedStmt.getResultSetHoldability(); |
430 | } |
431 | |
432 | throw SQLError.createSQLException("Statement already closed", |
433 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
434 | } catch (SQLException sqlEx) { |
435 | checkAndFireConnectionError(sqlEx); |
436 | } |
437 | |
438 | return Statement.CLOSE_CURRENT_RESULT; |
439 | } |
440 | |
441 | /* |
442 | * (non-Javadoc) |
443 | * |
444 | * @see java.sql.Statement#getResultSetType() |
445 | */ |
446 | public int getResultSetType() throws SQLException { |
447 | try { |
448 | if (this.wrappedStmt != null) { |
449 | return this.wrappedStmt.getResultSetType(); |
450 | } |
451 | |
452 | throw SQLError.createSQLException("Statement already closed", |
453 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
454 | } catch (SQLException sqlEx) { |
455 | checkAndFireConnectionError(sqlEx); |
456 | } |
457 | |
458 | return ResultSet.TYPE_FORWARD_ONLY; |
459 | } |
460 | |
461 | /* |
462 | * (non-Javadoc) |
463 | * |
464 | * @see java.sql.Statement#getUpdateCount() |
465 | */ |
466 | public int getUpdateCount() throws SQLException { |
467 | try { |
468 | if (this.wrappedStmt != null) { |
469 | return this.wrappedStmt.getUpdateCount(); |
470 | } |
471 | |
472 | throw SQLError.createSQLException("Statement already closed", |
473 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
474 | } catch (SQLException sqlEx) { |
475 | checkAndFireConnectionError(sqlEx); |
476 | } |
477 | |
478 | return -1; |
479 | } |
480 | |
481 | /* |
482 | * (non-Javadoc) |
483 | * |
484 | * @see java.sql.Statement#getWarnings() |
485 | */ |
486 | public SQLWarning getWarnings() throws SQLException { |
487 | try { |
488 | if (this.wrappedStmt != null) { |
489 | return this.wrappedStmt.getWarnings(); |
490 | } |
491 | |
492 | throw SQLError.createSQLException("Statement already closed", |
493 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
494 | } catch (SQLException sqlEx) { |
495 | checkAndFireConnectionError(sqlEx); |
496 | } |
497 | |
498 | return null; |
499 | } |
500 | |
501 | /* |
502 | * (non-Javadoc) |
503 | * |
504 | * @see java.sql.Statement#addBatch(java.lang.String) |
505 | */ |
506 | public void addBatch(String sql) throws SQLException { |
507 | try { |
508 | if (this.wrappedStmt != null) { |
509 | this.wrappedStmt.addBatch(sql); |
510 | } |
511 | } catch (SQLException sqlEx) { |
512 | checkAndFireConnectionError(sqlEx); |
513 | } |
514 | } |
515 | |
516 | /* |
517 | * (non-Javadoc) |
518 | * |
519 | * @see java.sql.Statement#cancel() |
520 | */ |
521 | public void cancel() throws SQLException { |
522 | try { |
523 | if (this.wrappedStmt != null) { |
524 | this.wrappedStmt.cancel(); |
525 | } |
526 | } catch (SQLException sqlEx) { |
527 | checkAndFireConnectionError(sqlEx); |
528 | } |
529 | } |
530 | |
531 | /* |
532 | * (non-Javadoc) |
533 | * |
534 | * @see java.sql.Statement#clearBatch() |
535 | */ |
536 | public void clearBatch() throws SQLException { |
537 | try { |
538 | if (this.wrappedStmt != null) { |
539 | this.wrappedStmt.clearBatch(); |
540 | } |
541 | } catch (SQLException sqlEx) { |
542 | checkAndFireConnectionError(sqlEx); |
543 | } |
544 | } |
545 | |
546 | /* |
547 | * (non-Javadoc) |
548 | * |
549 | * @see java.sql.Statement#clearWarnings() |
550 | */ |
551 | public void clearWarnings() throws SQLException { |
552 | try { |
553 | if (this.wrappedStmt != null) { |
554 | this.wrappedStmt.clearWarnings(); |
555 | } |
556 | } catch (SQLException sqlEx) { |
557 | checkAndFireConnectionError(sqlEx); |
558 | } |
559 | } |
560 | |
561 | /* |
562 | * (non-Javadoc) |
563 | * |
564 | * @see java.sql.Statement#close() |
565 | */ |
566 | public void close() throws SQLException { |
567 | try { |
568 | if (this.wrappedStmt != null) { |
569 | this.wrappedStmt.close(); |
570 | } |
571 | } catch (SQLException sqlEx) { |
572 | checkAndFireConnectionError(sqlEx); |
573 | } finally { |
574 | this.wrappedStmt = null; |
575 | this.pooledConnection = null; |
576 | } |
577 | } |
578 | |
579 | /* |
580 | * (non-Javadoc) |
581 | * |
582 | * @see java.sql.Statement#execute(java.lang.String, int) |
583 | */ |
584 | public boolean execute(String sql, int autoGeneratedKeys) |
585 | throws SQLException { |
586 | try { |
587 | if (this.wrappedStmt != null) { |
588 | return this.wrappedStmt.execute(sql, autoGeneratedKeys); |
589 | } |
590 | |
591 | throw SQLError.createSQLException("Statement already closed", |
592 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
593 | } catch (SQLException sqlEx) { |
594 | checkAndFireConnectionError(sqlEx); |
595 | } |
596 | |
597 | return false; // we actually never get here, but the compiler can't |
598 | // figure |
599 | |
600 | // that out |
601 | } |
602 | |
603 | /* |
604 | * (non-Javadoc) |
605 | * |
606 | * @see java.sql.Statement#execute(java.lang.String, int[]) |
607 | */ |
608 | public boolean execute(String sql, int[] columnIndexes) throws SQLException { |
609 | try { |
610 | if (this.wrappedStmt != null) { |
611 | return this.wrappedStmt.execute(sql, columnIndexes); |
612 | } |
613 | |
614 | throw SQLError.createSQLException("Statement already closed", |
615 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
616 | } catch (SQLException sqlEx) { |
617 | checkAndFireConnectionError(sqlEx); |
618 | } |
619 | |
620 | return false; // we actually never get here, but the compiler can't |
621 | // figure |
622 | |
623 | // that out |
624 | } |
625 | |
626 | /* |
627 | * (non-Javadoc) |
628 | * |
629 | * @see java.sql.Statement#execute(java.lang.String, java.lang.String[]) |
630 | */ |
631 | public boolean execute(String sql, String[] columnNames) |
632 | throws SQLException { |
633 | try { |
634 | if (this.wrappedStmt != null) { |
635 | return this.wrappedStmt.execute(sql, columnNames); |
636 | } |
637 | |
638 | throw SQLError.createSQLException("Statement already closed", |
639 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
640 | } catch (SQLException sqlEx) { |
641 | checkAndFireConnectionError(sqlEx); |
642 | } |
643 | |
644 | return false; // we actually never get here, but the compiler can't |
645 | // figure |
646 | |
647 | // that out |
648 | } |
649 | |
650 | /* |
651 | * (non-Javadoc) |
652 | * |
653 | * @see java.sql.Statement#execute(java.lang.String) |
654 | */ |
655 | public boolean execute(String sql) throws SQLException { |
656 | try { |
657 | if (this.wrappedStmt != null) { |
658 | return this.wrappedStmt.execute(sql); |
659 | } |
660 | |
661 | throw SQLError.createSQLException("Statement already closed", |
662 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
663 | } catch (SQLException sqlEx) { |
664 | checkAndFireConnectionError(sqlEx); |
665 | } |
666 | |
667 | return false; // we actually never get here, but the compiler can't |
668 | // figure |
669 | |
670 | // that out |
671 | } |
672 | |
673 | /* |
674 | * (non-Javadoc) |
675 | * |
676 | * @see java.sql.Statement#executeBatch() |
677 | */ |
678 | public int[] executeBatch() throws SQLException { |
679 | try { |
680 | if (this.wrappedStmt != null) { |
681 | return this.wrappedStmt.executeBatch(); |
682 | } |
683 | |
684 | throw SQLError.createSQLException("Statement already closed", |
685 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
686 | } catch (SQLException sqlEx) { |
687 | checkAndFireConnectionError(sqlEx); |
688 | } |
689 | |
690 | return null; // we actually never get here, but the compiler can't |
691 | // figure |
692 | |
693 | // that out |
694 | } |
695 | |
696 | /* |
697 | * (non-Javadoc) |
698 | * |
699 | * @see java.sql.Statement#executeQuery(java.lang.String) |
700 | */ |
701 | public ResultSet executeQuery(String sql) throws SQLException { |
702 | try { |
703 | if (this.wrappedStmt != null) { |
704 | |
705 | ResultSet rs = this.wrappedStmt.executeQuery(sql); |
706 | ((com.mysql.jdbc.ResultSet) rs).setWrapperStatement(this); |
707 | |
708 | return rs; |
709 | } |
710 | |
711 | throw SQLError.createSQLException("Statement already closed", |
712 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
713 | } catch (SQLException sqlEx) { |
714 | checkAndFireConnectionError(sqlEx); |
715 | } |
716 | |
717 | return null; // we actually never get here, but the compiler can't |
718 | // figure |
719 | |
720 | // that out |
721 | } |
722 | |
723 | /* |
724 | * (non-Javadoc) |
725 | * |
726 | * @see java.sql.Statement#executeUpdate(java.lang.String, int) |
727 | */ |
728 | public int executeUpdate(String sql, int autoGeneratedKeys) |
729 | throws SQLException { |
730 | try { |
731 | if (this.wrappedStmt != null) { |
732 | return this.wrappedStmt.executeUpdate(sql, autoGeneratedKeys); |
733 | } |
734 | |
735 | throw SQLError.createSQLException("Statement already closed", |
736 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
737 | } catch (SQLException sqlEx) { |
738 | checkAndFireConnectionError(sqlEx); |
739 | } |
740 | |
741 | return -1; // we actually never get here, but the compiler can't figure |
742 | |
743 | // that out |
744 | } |
745 | |
746 | /* |
747 | * (non-Javadoc) |
748 | * |
749 | * @see java.sql.Statement#executeUpdate(java.lang.String, int[]) |
750 | */ |
751 | public int executeUpdate(String sql, int[] columnIndexes) |
752 | throws SQLException { |
753 | try { |
754 | if (this.wrappedStmt != null) { |
755 | return this.wrappedStmt.executeUpdate(sql, columnIndexes); |
756 | } |
757 | |
758 | throw SQLError.createSQLException("Statement already closed", |
759 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
760 | } catch (SQLException sqlEx) { |
761 | checkAndFireConnectionError(sqlEx); |
762 | } |
763 | |
764 | return -1; // we actually never get here, but the compiler can't figure |
765 | |
766 | // that out |
767 | } |
768 | |
769 | /* |
770 | * (non-Javadoc) |
771 | * |
772 | * @see java.sql.Statement#executeUpdate(java.lang.String, |
773 | * java.lang.String[]) |
774 | */ |
775 | public int executeUpdate(String sql, String[] columnNames) |
776 | throws SQLException { |
777 | try { |
778 | if (this.wrappedStmt != null) { |
779 | return this.wrappedStmt.executeUpdate(sql, columnNames); |
780 | } |
781 | |
782 | throw SQLError.createSQLException("Statement already closed", |
783 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
784 | } catch (SQLException sqlEx) { |
785 | checkAndFireConnectionError(sqlEx); |
786 | } |
787 | |
788 | return -1; // we actually never get here, but the compiler can't figure |
789 | |
790 | // that out |
791 | } |
792 | |
793 | /* |
794 | * (non-Javadoc) |
795 | * |
796 | * @see java.sql.Statement#executeUpdate(java.lang.String) |
797 | */ |
798 | public int executeUpdate(String sql) throws SQLException { |
799 | try { |
800 | if (this.wrappedStmt != null) { |
801 | return this.wrappedStmt.executeUpdate(sql); |
802 | } |
803 | |
804 | throw SQLError.createSQLException("Statement already closed", |
805 | SQLError.SQL_STATE_ILLEGAL_ARGUMENT); |
806 | } catch (SQLException sqlEx) { |
807 | checkAndFireConnectionError(sqlEx); |
808 | } |
809 | |
810 | return -1; // we actually never get here, but the compiler can't figure |
811 | |
812 | // that out |
813 | } |
814 | |
815 | public void enableStreamingResults() throws SQLException { |
816 | try { |
817 | if (this.wrappedStmt != null) { |
818 | ((com.mysql.jdbc.Statement) this.wrappedStmt) |
819 | .enableStreamingResults(); |
820 | } else { |
821 | throw SQLError.createSQLException( |
822 | "No operations allowed after statement closed", |
823 | SQLError.SQL_STATE_GENERAL_ERROR); |
824 | } |
825 | } catch (SQLException sqlEx) { |
826 | checkAndFireConnectionError(sqlEx); |
827 | } |
828 | } |
829 | } |