| 1 24 25 package com.mysql.jdbc.jdbc2.optional; 26 27 import java.io.InputStream ; 28 import java.io.Reader ; 29 import java.math.BigDecimal ; 30 import java.net.URL ; 31 import java.sql.Array ; 32 import java.sql.Blob ; 33 import java.sql.CallableStatement ; 34 import java.sql.Clob ; 35 import java.sql.Date ; 36 import java.sql.PreparedStatement ; 37 import java.sql.Ref ; 38 import java.sql.SQLException ; 39 import java.sql.Time ; 40 import java.sql.Timestamp ; 41 import java.util.Calendar ; 42 import java.util.Map ; 43 44 import com.mysql.jdbc.SQLError; 45 46 52 public class CallableStatementWrapper extends PreparedStatementWrapper 53 implements CallableStatement { 54 55 60 public CallableStatementWrapper(ConnectionWrapper c, 61 MysqlPooledConnection conn, CallableStatement toWrap) { 62 super(c, conn, toWrap); 63 } 64 65 70 public void registerOutParameter(int parameterIndex, int sqlType) 71 throws SQLException { 72 try { 73 if (this.wrappedStmt != null) { 74 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 75 parameterIndex, sqlType); 76 } else { 77 throw new SQLException ( 78 "No operations allowed after statement closed", 79 SQLError.SQL_STATE_GENERAL_ERROR); 80 } 81 } catch (SQLException sqlEx) { 82 checkAndFireConnectionError(sqlEx); 83 } 84 } 85 86 91 public void registerOutParameter(int parameterIndex, int sqlType, int scale) 92 throws SQLException { 93 try { 94 if (this.wrappedStmt != null) { 95 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 96 parameterIndex, sqlType, scale); 97 } else { 98 throw new SQLException ( 99 "No operations allowed after statement closed", 100 SQLError.SQL_STATE_GENERAL_ERROR); 101 } 102 } catch (SQLException sqlEx) { 103 checkAndFireConnectionError(sqlEx); 104 } 105 } 106 107 112 public boolean wasNull() throws SQLException { 113 try { 114 if (this.wrappedStmt != null) { 115 return ((CallableStatement ) this.wrappedStmt).wasNull(); 116 } else { 117 throw new SQLException ( 118 "No operations allowed after statement closed", 119 SQLError.SQL_STATE_GENERAL_ERROR); 120 } 121 } catch (SQLException sqlEx) { 122 checkAndFireConnectionError(sqlEx); 123 } 124 125 return false; 126 } 127 128 133 public String getString(int parameterIndex) throws SQLException { 134 try { 135 if (this.wrappedStmt != null) { 136 return ((CallableStatement ) this.wrappedStmt) 137 .getString(parameterIndex); 138 } else { 139 throw new SQLException ( 140 "No operations allowed after statement closed", 141 SQLError.SQL_STATE_GENERAL_ERROR); 142 } 143 } catch (SQLException sqlEx) { 144 checkAndFireConnectionError(sqlEx); 145 } 146 return null; 147 } 148 149 154 public boolean getBoolean(int parameterIndex) throws SQLException { 155 try { 156 if (this.wrappedStmt != null) { 157 return ((CallableStatement ) this.wrappedStmt) 158 .getBoolean(parameterIndex); 159 } else { 160 throw new SQLException ( 161 "No operations allowed after statement closed", 162 SQLError.SQL_STATE_GENERAL_ERROR); 163 } 164 } catch (SQLException sqlEx) { 165 checkAndFireConnectionError(sqlEx); 166 } 167 168 return false; 169 } 170 171 176 public byte getByte(int parameterIndex) throws SQLException { 177 try { 178 if (this.wrappedStmt != null) { 179 return ((CallableStatement ) this.wrappedStmt) 180 .getByte(parameterIndex); 181 } else { 182 throw new SQLException ( 183 "No operations allowed after statement closed", 184 SQLError.SQL_STATE_GENERAL_ERROR); 185 } 186 } catch (SQLException sqlEx) { 187 checkAndFireConnectionError(sqlEx); 188 } 189 190 return 0; 191 } 192 193 198 public short getShort(int parameterIndex) throws SQLException { 199 try { 200 if (this.wrappedStmt != null) { 201 return ((CallableStatement ) this.wrappedStmt) 202 .getShort(parameterIndex); 203 } else { 204 throw new SQLException ( 205 "No operations allowed after statement closed", 206 SQLError.SQL_STATE_GENERAL_ERROR); 207 } 208 } catch (SQLException sqlEx) { 209 checkAndFireConnectionError(sqlEx); 210 } 211 212 return 0; 213 } 214 215 220 public int getInt(int parameterIndex) throws SQLException { 221 try { 222 if (this.wrappedStmt != null) { 223 return ((CallableStatement ) this.wrappedStmt) 224 .getInt(parameterIndex); 225 } else { 226 throw new SQLException ( 227 "No operations allowed after statement closed", 228 SQLError.SQL_STATE_GENERAL_ERROR); 229 } 230 } catch (SQLException sqlEx) { 231 checkAndFireConnectionError(sqlEx); 232 } 233 234 return 0; 235 } 236 237 242 public long getLong(int parameterIndex) throws SQLException { 243 try { 244 if (this.wrappedStmt != null) { 245 return ((CallableStatement ) this.wrappedStmt) 246 .getLong(parameterIndex); 247 } else { 248 throw new SQLException ( 249 "No operations allowed after statement closed", 250 SQLError.SQL_STATE_GENERAL_ERROR); 251 } 252 } catch (SQLException sqlEx) { 253 checkAndFireConnectionError(sqlEx); 254 } 255 256 return 0; 257 } 258 259 264 public float getFloat(int parameterIndex) throws SQLException { 265 try { 266 if (this.wrappedStmt != null) { 267 return ((CallableStatement ) this.wrappedStmt) 268 .getFloat(parameterIndex); 269 } else { 270 throw new SQLException ( 271 "No operations allowed after statement closed", 272 SQLError.SQL_STATE_GENERAL_ERROR); 273 } 274 } catch (SQLException sqlEx) { 275 checkAndFireConnectionError(sqlEx); 276 } 277 278 return 0; 279 } 280 281 286 public double getDouble(int parameterIndex) throws SQLException { 287 try { 288 if (this.wrappedStmt != null) { 289 return ((CallableStatement ) this.wrappedStmt) 290 .getDouble(parameterIndex); 291 } else { 292 throw new SQLException ( 293 "No operations allowed after statement closed", 294 SQLError.SQL_STATE_GENERAL_ERROR); 295 } 296 } catch (SQLException sqlEx) { 297 checkAndFireConnectionError(sqlEx); 298 } 299 300 return 0; 301 } 302 303 308 public BigDecimal getBigDecimal(int parameterIndex, int scale) 309 throws SQLException { 310 try { 311 if (this.wrappedStmt != null) { 312 return ((CallableStatement ) this.wrappedStmt).getBigDecimal( 313 parameterIndex, scale); 314 } else { 315 throw new SQLException ( 316 "No operations allowed after statement closed", 317 SQLError.SQL_STATE_GENERAL_ERROR); 318 } 319 } catch (SQLException sqlEx) { 320 checkAndFireConnectionError(sqlEx); 321 } 322 323 return null; 324 } 325 326 331 public byte[] getBytes(int parameterIndex) throws SQLException { 332 try { 333 if (this.wrappedStmt != null) { 334 return ((CallableStatement ) this.wrappedStmt) 335 .getBytes(parameterIndex); 336 } else { 337 throw new SQLException ( 338 "No operations allowed after statement closed", 339 SQLError.SQL_STATE_GENERAL_ERROR); 340 } 341 } catch (SQLException sqlEx) { 342 checkAndFireConnectionError(sqlEx); 343 } 344 345 return null; 346 } 347 348 353 public Date getDate(int parameterIndex) throws SQLException { 354 try { 355 if (this.wrappedStmt != null) { 356 return ((CallableStatement ) this.wrappedStmt) 357 .getDate(parameterIndex); 358 } else { 359 throw new SQLException ( 360 "No operations allowed after statement closed", 361 SQLError.SQL_STATE_GENERAL_ERROR); 362 } 363 } catch (SQLException sqlEx) { 364 checkAndFireConnectionError(sqlEx); 365 } 366 367 return null; 368 } 369 370 375 public Time getTime(int parameterIndex) throws SQLException { 376 try { 377 if (this.wrappedStmt != null) { 378 return ((CallableStatement ) this.wrappedStmt) 379 .getTime(parameterIndex); 380 } else { 381 throw new SQLException ( 382 "No operations allowed after statement closed", 383 SQLError.SQL_STATE_GENERAL_ERROR); 384 } 385 } catch (SQLException sqlEx) { 386 checkAndFireConnectionError(sqlEx); 387 } 388 389 return null; 390 } 391 392 397 public Timestamp getTimestamp(int parameterIndex) throws SQLException { 398 try { 399 if (this.wrappedStmt != null) { 400 return ((CallableStatement ) this.wrappedStmt) 401 .getTimestamp(parameterIndex); 402 } else { 403 throw new SQLException ( 404 "No operations allowed after statement closed", 405 SQLError.SQL_STATE_GENERAL_ERROR); 406 } 407 } catch (SQLException sqlEx) { 408 checkAndFireConnectionError(sqlEx); 409 } 410 411 return null; 412 } 413 414 419 public Object getObject(int parameterIndex) throws SQLException { 420 try { 421 if (this.wrappedStmt != null) { 422 return ((CallableStatement ) this.wrappedStmt) 423 .getObject(parameterIndex); 424 } else { 425 throw new SQLException ( 426 "No operations allowed after statement closed", 427 SQLError.SQL_STATE_GENERAL_ERROR); 428 } 429 } catch (SQLException sqlEx) { 430 checkAndFireConnectionError(sqlEx); 431 } 432 433 return null; 434 } 435 436 441 public BigDecimal getBigDecimal(int parameterIndex) throws SQLException { 442 try { 443 if (this.wrappedStmt != null) { 444 return ((CallableStatement ) this.wrappedStmt) 445 .getBigDecimal(parameterIndex); 446 } else { 447 throw new SQLException ( 448 "No operations allowed after statement closed", 449 SQLError.SQL_STATE_GENERAL_ERROR); 450 } 451 } catch (SQLException sqlEx) { 452 checkAndFireConnectionError(sqlEx); 453 } 454 455 return null; 456 } 457 458 463 public Object getObject(int parameterIndex, Map typeMap) 464 throws SQLException { 465 try { 466 if (this.wrappedStmt != null) { 467 return ((CallableStatement ) this.wrappedStmt).getObject( 468 parameterIndex, typeMap); 469 } else { 470 throw new SQLException ( 471 "No operations allowed after statement closed", 472 SQLError.SQL_STATE_GENERAL_ERROR); 473 } 474 } catch (SQLException sqlEx) { 475 checkAndFireConnectionError(sqlEx); 476 } 477 return null; 478 } 479 480 485 public Ref getRef(int parameterIndex) throws SQLException { 486 try { 487 if (this.wrappedStmt != null) { 488 return ((CallableStatement ) this.wrappedStmt) 489 .getRef(parameterIndex); 490 } else { 491 throw new SQLException ( 492 "No operations allowed after statement closed", 493 SQLError.SQL_STATE_GENERAL_ERROR); 494 } 495 } catch (SQLException sqlEx) { 496 checkAndFireConnectionError(sqlEx); 497 } 498 499 return null; 500 } 501 502 507 public Blob getBlob(int parameterIndex) throws SQLException { 508 try { 509 if (this.wrappedStmt != null) { 510 return ((CallableStatement ) this.wrappedStmt) 511 .getBlob(parameterIndex); 512 } else { 513 throw new SQLException ( 514 "No operations allowed after statement closed", 515 SQLError.SQL_STATE_GENERAL_ERROR); 516 } 517 } catch (SQLException sqlEx) { 518 checkAndFireConnectionError(sqlEx); 519 } 520 521 return null; 522 } 523 524 529 public Clob getClob(int parameterIndex) throws SQLException { 530 try { 531 if (this.wrappedStmt != null) { 532 return ((CallableStatement ) this.wrappedStmt) 533 .getClob(parameterIndex); 534 } else { 535 throw new SQLException ( 536 "No operations allowed after statement closed", 537 SQLError.SQL_STATE_GENERAL_ERROR); 538 } 539 } catch (SQLException sqlEx) { 540 checkAndFireConnectionError(sqlEx); 541 } 542 return null; 543 } 544 545 550 public Array getArray(int parameterIndex) throws SQLException { 551 try { 552 if (this.wrappedStmt != null) { 553 return ((CallableStatement ) this.wrappedStmt) 554 .getArray(parameterIndex); 555 } else { 556 throw new SQLException ( 557 "No operations allowed after statement closed", 558 SQLError.SQL_STATE_GENERAL_ERROR); 559 } 560 } catch (SQLException sqlEx) { 561 checkAndFireConnectionError(sqlEx); 562 } 563 return null; 564 } 565 566 571 public Date getDate(int parameterIndex, Calendar cal) throws SQLException { 572 try { 573 if (this.wrappedStmt != null) { 574 return ((CallableStatement ) this.wrappedStmt).getDate( 575 parameterIndex, cal); 576 } else { 577 throw new SQLException ( 578 "No operations allowed after statement closed", 579 SQLError.SQL_STATE_GENERAL_ERROR); 580 } 581 } catch (SQLException sqlEx) { 582 checkAndFireConnectionError(sqlEx); 583 } 584 return null; 585 } 586 587 592 public Time getTime(int parameterIndex, Calendar cal) throws SQLException { 593 try { 594 if (this.wrappedStmt != null) { 595 return ((CallableStatement ) this.wrappedStmt).getTime( 596 parameterIndex, cal); 597 } else { 598 throw new SQLException ( 599 "No operations allowed after statement closed", 600 SQLError.SQL_STATE_GENERAL_ERROR); 601 } 602 } catch (SQLException sqlEx) { 603 checkAndFireConnectionError(sqlEx); 604 } 605 return null; 606 } 607 608 613 public Timestamp getTimestamp(int parameterIndex, Calendar cal) 614 throws SQLException { 615 try { 616 if (this.wrappedStmt != null) { 617 return ((CallableStatement ) this.wrappedStmt).getTimestamp( 618 parameterIndex, cal); 619 } else { 620 throw new SQLException ( 621 "No operations allowed after statement closed", 622 SQLError.SQL_STATE_GENERAL_ERROR); 623 } 624 } catch (SQLException sqlEx) { 625 checkAndFireConnectionError(sqlEx); 626 } 627 return null; 628 } 629 630 636 public void registerOutParameter(int paramIndex, int sqlType, 637 String typeName) throws SQLException { 638 try { 639 if (this.wrappedStmt != null) { 640 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 641 paramIndex, sqlType, typeName); 642 } else { 643 throw new SQLException ( 644 "No operations allowed after statement closed", 645 SQLError.SQL_STATE_GENERAL_ERROR); 646 } 647 } catch (SQLException sqlEx) { 648 checkAndFireConnectionError(sqlEx); 649 } 650 } 651 652 658 public void registerOutParameter(String parameterName, int sqlType) 659 throws SQLException { 660 try { 661 if (this.wrappedStmt != null) { 662 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 663 parameterName, sqlType); 664 } else { 665 throw new SQLException ( 666 "No operations allowed after statement closed", 667 SQLError.SQL_STATE_GENERAL_ERROR); 668 } 669 } catch (SQLException sqlEx) { 670 checkAndFireConnectionError(sqlEx); 671 } 672 } 673 674 680 public void registerOutParameter(String parameterName, int sqlType, 681 int scale) throws SQLException { 682 try { 683 if (this.wrappedStmt != null) { 684 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 685 parameterName, sqlType, scale); 686 } else { 687 throw new SQLException ( 688 "No operations allowed after statement closed", 689 SQLError.SQL_STATE_GENERAL_ERROR); 690 } 691 } catch (SQLException sqlEx) { 692 checkAndFireConnectionError(sqlEx); 693 } 694 } 695 696 702 public void registerOutParameter(String parameterName, int sqlType, 703 String typeName) throws SQLException { 704 try { 705 if (this.wrappedStmt != null) { 706 ((CallableStatement ) this.wrappedStmt).registerOutParameter( 707 parameterName, sqlType, typeName); 708 } else { 709 throw new SQLException  |