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