| 1 22 package org.jboss.resource.adapter.jdbc; 23 24 import java.io.InputStream ; 25 import java.io.Reader ; 26 import java.math.BigDecimal ; 27 import java.net.URL ; 28 import java.sql.Array ; 29 import java.sql.Blob ; 30 import java.sql.Clob ; 31 import java.sql.Date ; 32 import java.sql.Ref ; 33 import java.sql.ResultSet ; 34 import java.sql.ResultSetMetaData ; 35 import java.sql.SQLException ; 36 import java.sql.SQLWarning ; 37 import java.sql.Statement ; 38 import java.sql.Time ; 39 import java.sql.Timestamp ; 40 import java.util.Calendar ; 41 import java.util.Map ; 42 43 49 public class WrappedResultSet implements ResultSet  50 { 51 52 private WrappedStatement statement; 53 54 55 private ResultSet resultSet; 56 57 58 private boolean closed = false; 59 60 61 private Object lock = new Object (); 62 63 69 public WrappedResultSet(WrappedStatement statement, ResultSet resultSet) 70 { 71 if (statement == null) 72 throw new IllegalArgumentException ("Null statement!"); 73 if (resultSet == null) 74 throw new IllegalArgumentException ("Null result set!"); 75 this.statement = statement; 76 this.resultSet = resultSet; 77 } 78 79 public boolean equals(Object o) 80 { 81 if (o == null) 82 return false; 83 else if (o == this) 84 return true; 85 else if (o instanceof WrappedResultSet) 86 return (resultSet.equals(((WrappedResultSet) o).resultSet)); 87 else if (o instanceof ResultSet ) 88 return resultSet.equals(o); 89 return false; 90 } 91 92 public int hashCode() 93 { 94 return resultSet.hashCode(); 95 } 96 97 public String toString() 98 { 99 return resultSet.toString(); 100 } 101 102 public ResultSet getUnderlyingResultSet() throws SQLException  103 { 104 checkState(); 105 return resultSet; 106 } 107 108 public boolean absolute(int row) throws SQLException  109 { 110 checkState(); 111 try 112 { 113 return resultSet.absolute(row); 114 } 115 catch (Throwable t) 116 { 117 throw checkException(t); 118 } 119 } 120 121 public void afterLast() throws SQLException  122 { 123 checkState(); 124 try 125 { 126 resultSet.afterLast(); 127 } 128 catch (Throwable t) 129 { 130 throw checkException(t); 131 } 132 } 133 134 public void beforeFirst() throws SQLException  135 { 136 checkState(); 137 try 138 { 139 resultSet.beforeFirst(); 140 } 141 catch (Throwable t) 142 { 143 throw checkException(t); 144 } 145 } 146 147 public void cancelRowUpdates() throws SQLException  148 { 149 checkState(); 150 try 151 { 152 resultSet.cancelRowUpdates(); 153 } 154 catch (Throwable t) 155 { 156 throw checkException(t); 157 } 158 } 159 160 public void clearWarnings() throws SQLException  161 { 162 checkState(); 163 try 164 { 165 resultSet.clearWarnings(); 166 } 167 catch (Throwable t) 168 { 169 throw checkException(t); 170 } 171 } 172 173 public void close() throws SQLException  174 { 175 synchronized (lock) 176 { 177 if (closed) 178 return; 179 closed = true; 180 } 181 statement.unregisterResultSet(this); 182 internalClose(); 183 } 184 185 public void deleteRow() throws SQLException  186 { 187 checkState(); 188 try 189 { 190 resultSet.deleteRow(); 191 } 192 catch (Throwable t) 193 { 194 throw checkException(t); 195 } 196 } 197 198 public int findColumn(String columnName) throws SQLException  199 { 200 checkState(); 201 try 202 { 203 return resultSet.findColumn(columnName); 204 } 205 catch (Throwable t) 206 { 207 throw checkException(t); 208 } 209 } 210 211 public boolean first() throws SQLException  212 { 213 checkState(); 214 try 215 { 216 return resultSet.first(); 217 } 218 catch (Throwable t) 219 { 220 throw checkException(t); 221 } 222 } 223 224 public Array getArray(int i) throws SQLException  225 { 226 checkState(); 227 try 228 { 229 return resultSet.getArray(i); 230 } 231 catch (Throwable t) 232 { 233 throw checkException(t); 234 } 235 } 236 237 public Array getArray(String colName) throws SQLException  238 { 239 checkState(); 240 try 241 { 242 return resultSet.getArray(colName); 243 } 244 catch (Throwable t) 245 { 246 throw checkException(t); 247 } 248 } 249 250 public InputStream getAsciiStream(int columnIndex) throws SQLException  251 { 252 checkState(); 253 try 254 { 255 return resultSet.getAsciiStream(columnIndex); 256 } 257 catch (Throwable t) 258 { 259 throw checkException(t); 260 } 261 } 262 263 public InputStream getAsciiStream(String columnName) throws SQLException  264 { 265 checkState(); 266 try 267 { 268 return resultSet.getAsciiStream(columnName); 269 } 270 catch (Throwable t) 271 { 272 throw checkException(t); 273 } 274 } 275 276 public BigDecimal getBigDecimal(int columnIndex) throws SQLException  277 { 278 checkState(); 279 try 280 { 281 return resultSet.getBigDecimal(columnIndex); 282 } 283 catch (Throwable t) 284 { 285 throw checkException(t); 286 } 287 } 288 289 292 public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException  293 { 294 checkState(); 295 try 296 { 297 return resultSet.getBigDecimal(columnIndex, scale); 298 } 299 catch (Throwable t) 300 { 301 throw checkException(t); 302 } 303 } 304 305 public BigDecimal getBigDecimal(String columnName) throws SQLException  306 { 307 checkState(); 308 try 309 { 310 return resultSet.getBigDecimal(columnName); 311 } 312 catch (Throwable t) 313 { 314 throw checkException(t); 315 } 316 } 317 318 321 public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException  322 { 323 checkState(); 324 try 325 { 326 return resultSet.getBigDecimal(columnName, scale); 327 } 328 catch (Throwable t) 329 { 330 throw checkException(t); 331 } 332 } 333 334 public InputStream getBinaryStream(int columnIndex) throws SQLException  335 { 336 checkState(); 337 try 338 { 339 return resultSet.getBinaryStream(columnIndex); 340 } 341 catch (Throwable t) 342 { 343 throw checkException(t); 344 } 345 } 346 347 public InputStream getBinaryStream(String columnName) throws SQLException  348 { 349 checkState(); 350 try 351 { 352 return resultSet.getBinaryStream(columnName); 353 } 354 catch (Throwable t) 355 { 356 throw checkException(t); 357 } 358 } 359 360 public Blob getBlob(int i) throws SQLException  361 { 362 checkState(); 363 try 364 { 365 return resultSet.getBlob(i); 366 } 367 catch (Throwable t) 368 { 369 throw checkException(t); 370 } 371 } 372 373 public Blob getBlob(String colName) throws SQLException  374 { 375 checkState(); 376 try 377 { 378 return resultSet.getBlob(colName); 379 } 380 catch (Throwable t) 381 { 382 throw checkException(t); 383 } 384 } 385 386 public boolean getBoolean(int columnIndex) throws SQLException  387 { 388 checkState(); 389 try 390 { 391 return resultSet.getBoolean(columnIndex); 392 } 393 catch (Throwable t) 394 { 395 throw checkException(t); 396 } 397 } 398 399 public boolean getBoolean(String columnName) throws SQLException  400 { 401 checkState(); 402 try 403 { 404 return resultSet.getBoolean(columnName); 405 } 406 catch (Throwable t) 407 { 408 throw checkException(t); 409 } 410 } 411 412 public byte getByte(int columnIndex) throws SQLException  413 { 414 checkState(); 415 try 416 { 417 return resultSet.getByte(columnIndex); 418 } 419 catch (Throwable t) 420 { 421 throw checkException(t); 422 } 423 } 424 425 public byte getByte(String columnName) throws SQLException  426 { 427 checkState(); 428 try 429 { 430 return resultSet.getByte(columnName); 431 } 432 catch (Throwable t) 433 { 434 throw checkException(t); 435 } 436 } 437 438 public byte[] getBytes(int columnIndex) throws SQLException  439 { 440 checkState(); 441 try 442 { 443 return resultSet.getBytes(columnIndex); 444 } 445 catch (Throwable t) 446 { 447 throw checkException(t); 448 } 449 } 450 451 public byte[] getBytes(String columnName) throws SQLException  452 { 453 checkState(); 454 try 455 { 456 return resultSet.getBytes(columnName); 457 } 458 catch (Throwable t) 459 { 460 throw checkException(t); 461 } 462 } 463 464 public Reader getCharacterStream(int columnIndex) throws SQLException  465 { 466 checkState(); 467 try 468 { 469 return resultSet.getCharacterStream(columnIndex); 470 } 471 catch (Throwable t) 472 { 473 throw checkException(t); 474 } 475 } 476 477 public Reader getCharacterStream(String columnName) throws SQLException  478 { 479 checkState(); 480 try 481 { 482 return resultSet.getCharacterStream(columnName); 483 } 484 catch (Throwable t) 485 { 486 throw checkException(t); 487 } 488 } 489 490 public Clob getClob(int i) throws SQLException  491 { 492 checkState(); 493 try 494 { 495 return resultSet.getClob(i); 496 } 497 catch (Throwable t) 498 { 499 throw checkException(t); 500 } 501 } 502 503 public Clob getClob(String colName) throws SQLException  504 { 505 checkState(); 506 try 507 { 508 return resultSet.getClob(colName); 509 } 510 catch (Throwable t) 511 { 512 throw checkException(t); 513 } 514 } 515 516 public int getConcurrency() throws SQLException  517 { 518 checkState(); 519 try 520 { 521 return resultSet.getConcurrency(); 522 } 523 catch (Throwable t) 524 { 525 throw checkException(t); 526 } 527 } 528 529 public String getCursorName() throws SQLException  530 { 531 checkState(); 532 try 533 { 534 return resultSet.getCursorName(); 535 } 536 catch (Throwable t) 537 { 538 throw checkException(t); 539 } 540 } 541 542 public Date getDate(int columnIndex) throws SQLException  543 { 544 checkState(); 545 try 546 { 547 return resultSet.getDate(columnIndex); 548 } 549 catch (Throwable t) 550 { 551 throw checkException(t); 552 } 553 } 554 555 public Date getDate(int columnIndex, Calendar cal) throws SQLException  556 { 557 checkState(); 558 try 559 { 560 return resultSet.getDate(columnIndex, cal); 561 } 562 catch (Throwable t) 563 { 564 throw checkException(t); 565 } 566 } 567 568 public Date getDate(String columnName) throws SQLException  569 { 570 checkState(); 571 try 572 { 573 return resultSet.getDate(columnName); 574 } 575 catch (Throwable t) 576 { 577 throw checkException(t); 578 } 579 } 580 581 public Date getDate(String columnName, Calendar cal) throws SQLException  582 { 583 checkState(); 584 try 585 { 586 return resultSet.getDate(columnName, cal); 587 } 588 catch (Throwable t) 589 { 590 throw checkException(t); 591 } 592 } 593 594 public double getDouble(int columnIndex) throws SQLException  595 { 596 checkState(); 597 try 598 { 599 return resultSet.getDouble(columnIndex); 600 } 601 catch (Throwable t) 602 { 603 throw checkException(t); 604 } 605 } 606 607 public double getDouble(String columnName) throws SQLException  608 { 609 checkState(); 610 try 611 { 612 return resultSet.getDouble(columnName); 613 } 614 catch (Throwable t) 615 { 616 throw checkException(t); 617 } 618 } 619 620 public int getFetchDirection() throws SQLException  621 { 622 checkState(); 623 try 624 { 625 return resultSet.getFetchDirection(); 626 } 627 catch (Throwable t) 628 { 629 throw checkException(t); 630 } 631 } 632 633 public int getFetchSize() throws SQLException  634 { 635 checkState(); 636 try 637 { 638 return resultSet.getFetchSize(); 639 } 640 catch (Throwable t) 641 { 642 throw checkException(t); 643 } 644 } 645 646 public float getFloat(int columnIndex) throws SQLException  647 { 648 checkState(); 649 try 650 { 651 return resultSet.getFloat(columnIndex); 652 } 653 catch (Throwable t) 654 { 655 throw checkException(t); 656 } 657 } 658 659 public float getFloat(String columnName) throws SQLException  660 { 661 checkState(); 662 try 663 { 664 return resultSet.getFloat(columnName); 665 } 666 catch (Throwable t) 667 { 668 throw checkException(t); 669 } 670 } 671 672 public int getInt(int columnIndex) throws SQLException  673 { 674 checkState(); 675 try 676 { 677 return resultSet.getInt(columnIndex); 678 } 679 catch (Throwable t) 680 { 681 throw checkException(t); 682 } 683 } 684 685 public int getInt(String columnName) throws SQLException  686 { 687 checkState(); 688 try 689 { 690 return resultSet.getInt(columnName); 691 } 692 catch (Throwable t) 693 { 694 throw checkException(t); 695 } 696 } 697 698 public long getLong(int columnIndex) throws SQLException  699 { 700 checkState(); 701 try 702 { 703 return resultSet.getLong(columnIndex); 704 } 705 catch (Throwable t) 706 { 707 throw checkException(t); 708 } 709 } 710 711 public long getLong(String columnName) throws SQLException  712 { 713 checkState(); 714 try 715 { 716 return resultSet.getLong(columnName); 717 } 718 catch (Throwable t) 719 { 720 throw checkException(t); 721 } 722 } 723 724 public ResultSetMetaData getMetaData() throws SQLException  725 { 726 checkState(); 727 try 728 { 729 return resultSet.getMetaData(); 730 } 731 catch (Throwable t) 732 { 733 throw checkException(t); 734 } 735 } 736 737 public Object getObject(int columnIndex) throws SQLException  738 { 739 checkState(); 740 try 741 { 742 return resultSet.getObject(columnIndex); 743 } 744 catch (Throwable t) 745 { 746 throw checkException(t); 747 } 748 } 749 750 public Object getObject(int i, Map map) throws SQLException  751 { 752 checkState(); 753 try 754 { 755 return resultSet.getObject(i, map); 756 } 757 catch (Throwable t) 758 { 759 throw checkException(t); 760 } 761 } 762 763 public Object getObject(String columnName) throws SQLException  764 { 765 checkState(); 766 try 767 { 768 return resultSet.getObject(columnName); 769 } 770 catch (Throwable t) 771 { 772 throw checkException(t); 773 } 774 } 775 776 public Object getObject(String colName, Map map) throws SQLException  777 { 778 checkState(); 779 try 780 { 781 return resultSet.getObject(colName, map); 782 } 783 catch (Throwable t) 784 { 785 throw checkException(t); 786 } 787 } 788 789 public Ref getRef(int i) throws SQLException  790 { 791 checkState(); 792 try 793 { 794 return resultSet.getRef(i); 795 } 796 catch (Throwable t) 797 { 798 throw checkException(t); 799 } 800 } 801 802 public Ref getRef(String colName) throws SQLException  803 { 804 checkState(); 805 try 806 { 807 return resultSet.getRef(colName); 808 } 809 catch (Throwable t) 810 { 811 throw checkException(t); 812 } 813 } 814 815 public int getRow() throws SQLException  816 { 817 checkState(); 818 try 819 { 820 return resultSet.getRow(); 821 } 822 catch (Throwable t) 823 { 824 throw checkException(t); 825 } 826 } 827 828 public short getShort(int columnIndex) throws SQLException  829 { 830 checkState(); 831 try 832 { 833 return resultSet.getShort(columnIndex); 834 } 835 catch (Throwable t) 836 { 837 throw checkException(t); 838 } 839 } 840 841 public short getShort(String columnName) throws SQLException  842 { 843 checkState(); 844 try 845 { 846 return resultSet.getShort(columnName); 847 } 848 catch (Throwable t) 849 { 850 throw checkException(t); 851 } 852 } 853 854 public Statement getStatement() throws SQLException  855 { 856 checkState(); 857 return statement; 858 } 859 860 public String getString(int columnIndex) throws SQLException  861 { 862 checkState(); 863 try 864 { 865 return resultSet.getString(columnIndex); 866 } 867 catch (Throwable t) 868 { 869 throw checkException(t); 870 } 871 } 872 873 public String getString(String columnName) throws SQLException  874 { 875 checkState(); 876 try 877 { 878 return resultSet.getString(columnName); 879 } 880 catch (Throwable t) 881 { 882 throw checkException(t); 883 } 884 } 885 886 public Time getTime(int columnIndex) throws SQLException  887 { 888 checkState(); 889 try 890 { 891 return resultSet.getTime(columnIndex); 892 } 893 catch (Throwable t) 894 { 895 throw checkException(t); 896 } 897 } 898 899 public Time getTime(int columnIndex, Calendar cal) throws SQLException |