1 19 package org.openharmonise.commons.dsi; 20 21 import java.io.*; 22 import java.math.BigDecimal ; 23 import java.net.URL ; 24 import java.sql.*; 25 import java.util.*; 26 27 38 public class HarmoniseResultSet implements ResultSet { 39 40 43 Statement m_stmt = null; 44 45 48 ResultSet m_rs = null; 49 50 56 Map m_rowcache = new Hashtable(); 57 58 65 HarmoniseResultSet(Statement stmt, ResultSet rs) { 66 m_stmt = stmt; 67 m_rs = rs; 68 } 69 70 71 74 public String getString(String str) throws SQLException { 75 String sResult = null; 76 77 String sKey = this.getCacheKey(str); 78 79 if(m_rowcache.size() > 0) { 80 sResult = (String ) m_rowcache.get(sKey); 81 } 82 83 if(sResult == null) { 84 sResult = m_rs.getString(str); 85 if(sResult != null) { 86 m_rowcache.put(sKey, sResult); 87 } 88 } 89 90 return sResult; 91 } 92 93 96 public String getString(int n) throws SQLException { 97 String sResult = null; 98 99 String sKey = this.getCacheKey(n); 100 101 if(m_rowcache.size() > 0) { 102 sResult = (String ) m_rowcache.get(sKey); 103 } 104 105 if(sResult == null) { 106 sResult = m_rs.getString(n); 107 if(sResult != null) { 108 m_rowcache.put(sKey, sResult); 109 } 110 } 111 112 return sResult; 113 } 114 115 116 119 public boolean next() throws SQLException { 120 m_rowcache.clear(); 121 return (m_rs.next()); 122 } 123 124 127 public void close() throws SQLException { 128 m_rs.close(); 129 m_stmt.close(); 130 } 131 132 133 139 private String getCacheKey(int n) { 140 return String.valueOf(n); 141 } 142 143 150 private String getCacheKey(String sColumn) throws SQLException { 151 String sKey = null; 152 153 int nCols = m_rs.getMetaData().getColumnCount(); 154 155 boolean bFound = false; 156 int i=1; 157 158 while(i <= nCols && bFound == false) { 159 if(sColumn.equalsIgnoreCase(m_rs.getMetaData().getColumnName(i)) == true) { 160 bFound = true; 161 sKey = String.valueOf(i); 162 } 163 i++; 164 } 165 166 return sKey; 167 } 168 169 170 173 public boolean absolute(int arg0) throws SQLException { 174 return m_rs.absolute(arg0); 175 } 176 177 180 public void afterLast() throws SQLException { 181 m_rs.afterLast(); 182 } 183 184 187 public void beforeFirst() throws SQLException { 188 m_rs.beforeFirst(); 189 } 190 191 192 195 public void cancelRowUpdates() throws SQLException { 196 m_rs.cancelRowUpdates(); 197 } 198 199 200 203 public void deleteRow() throws SQLException { 204 m_rs.deleteRow(); 205 } 206 207 210 public boolean equals(Object arg0) { 211 return m_rs.equals(arg0); 212 } 213 214 215 218 public boolean first() throws SQLException { 219 return m_rs.first(); 220 } 221 222 223 226 public Array getArray(int arg0) throws SQLException { 227 return m_rs.getArray(arg0); 228 } 229 230 231 234 public Array getArray(String arg0) throws SQLException { 235 return m_rs.getArray(arg0); 236 } 237 238 239 242 public BigDecimal getBigDecimal(int arg0) throws SQLException { 243 return m_rs.getBigDecimal(arg0); 244 } 245 246 247 250 public BigDecimal getBigDecimal(String arg0) throws SQLException { 251 return m_rs.getBigDecimal(arg0); 252 } 253 254 255 258 public Blob getBlob(int arg0) throws SQLException { 259 return m_rs.getBlob(arg0); 260 } 261 262 263 266 public Blob getBlob(String arg0) throws SQLException { 267 return m_rs.getBlob(arg0); 268 } 269 270 271 274 public Reader getCharacterStream(int arg0) throws SQLException { 275 return m_rs.getCharacterStream(arg0); 276 } 277 278 279 282 public Reader getCharacterStream(String arg0) throws SQLException { 283 return m_rs.getCharacterStream(arg0); 284 } 285 286 287 290 public Clob getClob(int arg0) throws SQLException { 291 return m_rs.getClob(arg0); 292 } 293 294 295 298 public Clob getClob(String arg0) throws SQLException { 299 return m_rs.getClob(arg0); 300 } 301 302 303 306 public int getConcurrency() throws SQLException { 307 return m_rs.getConcurrency(); 308 } 309 310 311 314 public java.sql.Date getDate(int arg0, Calendar arg1) throws SQLException { 315 return m_rs.getDate(arg0, arg1); 316 } 317 318 321 public java.sql.Date getDate(String arg0, Calendar arg1) throws SQLException { 322 return m_rs.getDate(arg0, arg1); 323 } 324 325 326 329 public int getFetchDirection() throws SQLException { 330 return m_rs.getFetchDirection(); 331 } 332 333 334 337 public int getFetchSize() throws SQLException { 338 return m_rs.getFetchSize(); 339 } 340 341 342 345 public Object getObject(int arg0, Map arg1) throws SQLException { 346 return m_rs.getObject(arg0, arg1); 347 } 348 349 350 353 public Object getObject(String arg0, Map arg1) throws SQLException { 354 return m_rs.getObject(arg0, arg1); 355 } 356 357 358 361 public Ref getRef(int arg0) throws SQLException { 362 return m_rs.getRef(arg0); 363 } 364 365 366 369 public Ref getRef(String arg0) throws SQLException { 370 return m_rs.getRef(arg0); 371 } 372 373 374 377 public int getRow() throws SQLException { 378 return m_rs.getRow(); 379 } 380 381 382 385 public Statement getStatement() throws SQLException { 386 return m_rs.getStatement(); 387 } 388 389 390 393 public Time getTime(int arg0, Calendar arg1) throws SQLException { 394 return m_rs.getTime(arg0, arg1); 395 } 396 397 398 401 public Time getTime(String arg0, Calendar arg1) throws SQLException { 402 return m_rs.getTime(arg0, arg1); 403 } 404 405 406 409 public Timestamp getTimestamp(int arg0, Calendar arg1) 410 throws SQLException { 411 return m_rs.getTimestamp(arg0, arg1); 412 } 413 414 415 418 public Timestamp getTimestamp(String arg0, Calendar arg1) 419 throws SQLException { 420 return m_rs.getTimestamp(arg0, arg1); 421 } 422 423 424 427 public int getType() throws SQLException { 428 return m_rs.getType(); 429 } 430 431 432 435 public URL getURL(int arg0) throws SQLException { 436 return m_rs.getURL(arg0); 437 } 438 439 440 443 public URL getURL(String arg0) throws SQLException { 444 return m_rs.getURL(arg0); 445 } 446 447 450 public int hashCode() { 451 return m_rs.hashCode(); 452 } 453 454 455 458 public void insertRow() throws SQLException { 459 m_rs.insertRow(); 460 } 461 462 463 466 public boolean isAfterLast() throws SQLException { 467 return m_rs.isAfterLast(); 468 } 469 470 471 474 public boolean isBeforeFirst() throws SQLException { 475 return m_rs.isBeforeFirst(); 476 } 477 478 479 482 public boolean isFirst() throws SQLException { 483 return m_rs.isFirst(); 484 } 485 486 487 490 public boolean isLast() throws SQLException { 491 return m_rs.isLast(); 492 } 493 494 495 498 public boolean last() throws SQLException { 499 return m_rs.last(); 500 } 501 502 505 public void moveToCurrentRow() throws SQLException { 506 m_rs.moveToCurrentRow(); 507 } 508 509 510 513 public void moveToInsertRow() throws SQLException { 514 m_rs.moveToInsertRow(); 515 } 516 517 518 521 public boolean previous() throws SQLException { 522 return m_rs.previous(); 523 } 524 525 526 529 public void refreshRow() throws SQLException { 530 m_rs.refreshRow(); 531 } 532 533 534 537 public boolean relative(int arg0) throws SQLException { 538 return m_rs.relative(arg0); 539 } 540 541 542 545 public boolean rowDeleted() throws SQLException { 546 return m_rs.rowDeleted(); 547 } 548 549 550 553 public boolean rowInserted() throws SQLException { 554 return m_rs.rowInserted(); 555 } 556 557 558 561 public boolean rowUpdated() throws SQLException { 562 return m_rs.rowUpdated(); 563 } 564 565 566 569 public void setFetchDirection(int arg0) throws SQLException { 570 m_rs.setFetchDirection(arg0); 571 } 572 573 574 577 public void setFetchSize(int arg0) throws SQLException { 578 m_rs.setFetchSize(arg0); 579 } 580 581 584 public String toString() { 585 return m_rs.toString(); 586 } 587 588 589 592 public void updateArray(int arg0, Array arg1) throws SQLException { 593 m_rs.updateArray(arg0, arg1); 594 } 595 596 597 600 public void updateArray(String arg0, Array arg1) throws SQLException { 601 m_rs.updateArray(arg0, arg1); 602 } 603 604 605 608 public void updateAsciiStream(int arg0, InputStream arg1, int arg2) 609 throws SQLException { 610 m_rs.updateAsciiStream(arg0, arg1, arg2); 611 } 612 613 614 617 public void updateAsciiStream(String arg0, InputStream arg1, int arg2) 618 throws SQLException { 619 m_rs.updateAsciiStream(arg0, arg1, arg2); 620 } 621 622 623 626 public void updateBigDecimal(int arg0, BigDecimal arg1) 627 throws SQLException { 628 m_rs.updateBigDecimal(arg0, arg1); 629 } 630 631 632 635 public void updateBigDecimal(String arg0, BigDecimal arg1) 636 throws SQLException { 637 m_rs.updateBigDecimal(arg0, arg1); 638 } 639 640 641 644 public void updateBinaryStream(int arg0, InputStream arg1, int arg2) 645 throws SQLException { 646 m_rs.updateBinaryStream(arg0, arg1, arg2); 647 } 648 649 650 653 public void updateBinaryStream(String arg0, InputStream arg1, int arg2) 654 throws SQLException { 655 m_rs.updateBinaryStream(arg0, arg1, arg2); 656 } 657 658 659 662 public void updateBlob(int arg0, Blob arg1) throws SQLException { 663 m_rs.updateBlob(arg0, arg1); 664 } 665 666 669 public void updateBlob(String arg0, Blob arg1) throws SQLException { 670 m_rs.updateBlob(arg0, arg1); 671 } 672 673 676 public void updateBoolean(int arg0, boolean arg1) throws SQLException { 677 m_rs.updateBoolean(arg0, arg1); 678 } 679 680 683 public void updateBoolean(String arg0, boolean arg1) throws SQLException { 684 m_rs.updateBoolean(arg0, arg1); 685 } 686 687 690 public void updateByte(int arg0, byte arg1) throws SQLException { 691 m_rs.updateByte(arg0, arg1); 692 } 693 694 697 public void updateByte(String arg0, byte arg1) throws SQLException { 698 m_rs.updateByte(arg0, arg1); 699 } 700 701 704 public void updateBytes(int arg0, byte[] arg1) throws SQLException { 705 m_rs.updateBytes(arg0, arg1); 706 } 707 708 711 public void updateBytes(String arg0, byte[] arg1) throws SQLException { 712 m_rs.updateBytes(arg0, arg1); 713 } 714 715 718 public void updateCharacterStream(int arg0, Reader arg1, int arg2) 719 throws SQLException { 720 m_rs.updateCharacterStream(arg0, arg1, arg2); 721 } 722 723 726 public void updateCharacterStream(String arg0, Reader arg1, int arg2) 727 throws SQLException { 728 m_rs.updateCharacterStream(arg0, arg1, arg2); 729 } 730 731 734 public void updateClob(int arg0, Clob arg1) throws SQLException { 735 m_rs.updateClob(arg0, arg1); 736 } 737 738 741 public void updateClob(String arg0, Clob arg1) throws SQLException { 742 m_rs.updateClob(arg0, arg1); 743 } 744 745 748 public void updateDate(int arg0, java.sql.Date arg1) throws SQLException { 749 m_rs.updateDate(arg0, arg1); 750 } 751 752 755 public void updateDate(String arg0, java.sql.Date arg1) throws SQLException { 756 m_rs.updateDate(arg0, arg1); 757 } 758 759 762 public void updateDouble(int arg0, double arg1) throws SQLException { 763 m_rs.updateDouble(arg0, arg1); 764 } 765 766 769 public void updateDouble(String arg0, double arg1) throws SQLException { 770 m_rs.updateDouble(arg0, arg1); 771 } 772 773 776 public void updateFloat(int arg0, float arg1) throws SQLException { 777 m_rs.updateFloat(arg0, arg1); 778 } 779 780 783 public void updateFloat(String arg0, float arg1) throws SQLException { 784 m_rs.updateFloat(arg0, arg1); 785 } 786 787 790 public void updateInt(int arg0, int arg1) throws SQLException { 791 m_rs.updateInt(arg0, arg1); 792 } 793 794 797 public void updateInt(String arg0, int arg1) throws SQLException { 798 m_rs.updateInt(arg0, arg1); 799 } 800 801 804 public void updateLong(int arg0, long arg1) throws SQLException { 805 m_rs.updateLong(arg0, arg1); 806 } 807 808 811 public void updateLong(String arg0, long arg1) throws SQLException { 812 m_rs.updateLong(arg0, arg1); 813 } 814 815 818 public void updateNull(int arg0) throws SQLException { 819 m_rs.updateNull(arg0); 820 } 821 822 825 public void updateNull(String arg0) throws SQLException { 826 m_rs.updateNull(arg0); 827 } 828 829 832 public void updateObject(int arg0, Object arg1) throws SQLException { 833 m_rs.updateObject(arg0, arg1); 834 } 835 836 839 public void updateObject(int arg0, Object arg1, int arg2) 840 throws SQLException { 841 m_rs.updateObject(arg0, arg1, arg2); 842 } 843 844 847 public void updateObject(String arg0, Object arg1) throws SQLException { 848 m_rs.updateObject(arg0, arg1); 849 } 850 851 854 public void updateObject(String arg0, Object arg1, int arg2) 855 throws SQLException { 856 m_rs.updateObject(arg0, arg1, arg2); 857 } 858 859 862 public void updateRef(int arg0, Ref arg1) throws SQLException { 863 m_rs.updateRef(arg0, arg1); 864 } 865 866 869 public void updateRef(String arg0, Ref arg1) throws SQLException { 870 m_rs.updateRef(arg0, arg1); 871 } 872 873 876 public void updateRow() throws SQLException { 877 m_rs.updateRow(); 878 } 879 880 883 public void updateShort(int arg0, short arg1) throws SQLException { 884 m_rs.updateShort(arg0, arg1); 885 } 886 887 890 public void updateShort(String arg0, short arg1) throws SQLException { 891 m_rs.updateShort(arg0, arg1); 892 } 893 894 897 public void updateString(int arg0, String arg1) throws SQLException { 898 m_rs.updateString(arg0, arg1); 899 } 900 901 904 public void updateString(String arg0, String arg1) throws SQLException { 905 m_rs.updateString(arg0, arg1); 906 } 907 908 909 912 public void updateTime(int arg0, Time arg1) throws SQLException { 913 m_rs.updateTime(arg0, arg1); 914 } 915 916 919 public void updateTime(String arg0, Time arg1) throws SQLException { 920 m_rs.updateTime(arg0, arg1); 921 } 922 923 926 public void updateTimestamp(int arg0, Timestamp arg1) throws SQLException { 927 m_rs.updateTimestamp(arg0, arg1); 928 } 929 930 933 public void updateTimestamp(String arg0, Timestamp arg1) 934 throws SQLException { 935 m_rs.updateTimestamp(arg0, arg1); 936 } 937 938 941 public Timestamp getTimestamp(int arg0) throws SQLException { 942 return m_rs.getTimestamp(arg0); 943 } 944 945 948 public boolean getBoolean(String arg0) throws SQLException { 949 return m_rs.getBoolean(arg0); 950 } 951 952 955 public Object getObject(int arg0) throws SQLException { 956 return m_rs.getObject(arg0); 957 } 958 959 962 public Time getTime(int arg0) throws SQLException { 963 return m_rs.getTime(arg0); 964 } 965 966 969 public byte[] getBytes(int arg0) throws SQLException { 970 return m_rs.getBytes(arg0); 971 } 972 973 976 public byte[] getBytes(String arg0) throws SQLException { 977 return m_rs.getBytes(arg0); 978 } 979 980 983 public String getCursorName() throws SQLException { 984 return m_rs.getCursorName(); 985 } 986 987 990 public void clearWarnings() throws SQLException { 991 m_rs.clearWarnings(); 992 } 993 994 997 public InputStream getUnicodeStream(int arg0) throws SQLException { 998 return m_rs.getUnicodeStream(arg0); 999 } 1000 1001 1004 public long getLong(String arg0) throws SQLException { 1005 return m_rs.getLong(arg0); 1006 } 1007 1008 1011 public ResultSetMetaData getMetaData() throws SQLException { 1012 return m_rs.getMetaData(); 1013 } 1014 1015 1018 public BigDecimal getBigDecimal(int arg0, int arg1) throws SQLException { 1019 return m_rs.getBigDecimal(arg0, arg1); 1020 } 1021 1022 1025 public float getFloat(int arg0) throws SQLException { 1026 return m_rs.getFloat(arg0); 1027 } 1028 1029 1032 public int findColumn(String arg0) throws SQLException { 1033 return m_rs.findColumn(arg0); 1034 } 1035 1036 1039 public BigDecimal getBigDecimal(String arg0, int arg1) 1040 throws SQLException { 1041 return m_rs.getBigDecimal(arg0, arg1); 1042 } 1043 1044 1047 public Timestamp getTimestamp(String arg0) throws SQLException { 1048 return m_rs.getTimestamp(arg0); 1049 } 1050 1051 1054 public double getDouble(String arg0) throws SQLException { 1055 return m_rs.getDouble(arg0); 1056 } 1057 1058 1061 public int getInt(String str) throws SQLException { 1062 String sKey = this.getCacheKey(str); 1063 Integer intResult = null; 1064 1065 if(m_rowcache.size() > 0) { 1066 intResult = (Integer ) m_rowcache.get(sKey); 1067 } 1068 1069 if(intResult == null) { 1070 intResult = new Integer (m_rs.getInt(str)); 1071 if(intResult != null) { 1072 m_rowcache.put(sKey, intResult); 1073 } 1074 } 1075 1076 return intResult.intValue(); 1077 } 1078 1079 1082 public java.sql.Date getDate(String arg0) throws SQLException { 1083 return m_rs.getDate(arg0); 1084 } 1085 1086 1089 public Time getTime(String arg0) throws SQLException { 1090 return m_rs.getTime(arg0); 1091 } 1092 1093 1096 public short getShort(String arg0) throws SQLException { 1097 return m_rs.getShort(arg0); 1098 } 1099 1100 1103 public InputStream getAsciiStream(String arg0) throws SQLException { 1104 return m_rs.getAsciiStream(arg0); 1105 } 1106 1107 1110 public boolean wasNull() throws SQLException { 1111 return m_rs.wasNull(); 1112 } 1113 1114 1117 public InputStream getBinaryStream(int arg0) throws SQLException { 1118 return m_rs.getBinaryStream(arg0); 1119 } 1120 1121 1124 public java.sql.Date getDate(int arg0) throws SQLException { 1125 return m_rs.getDate(arg0); 1126 } 1127 1128 1131 public SQLWarning getWarnings() throws SQLException { 1132 return m_rs.getWarnings(); 1133 } 1134 1135 1138 public InputStream getAsciiStream(int arg0) throws SQLException { 1139 return m_rs.getAsciiStream(arg0); 1140 } 1141 1142 1145 public long getLong(int arg0) throws SQLException { 1146 return m_rs.getLong(arg0); 1147 } 1148 1149 1152 public InputStream getUnicodeStream(String arg0) throws SQLException { 1153 return m_rs.getUnicodeStream(arg0); 1154 } 1155 1156 1159 public byte getByte(int arg0) throws SQLException { 1160 return m_rs.getByte(arg0); 1161 } 1162 1163 1166 public Object getObject(String arg0) throws SQLException { 1167 return m_rs.getObject(arg0); 1168 } 1169 1170 1173 public int getInt(int n) throws SQLException { 1174 String sKey = this.getCacheKey(n); 1175 Integer intResult = null; 1176 1177 if(m_rowcache.size() > 0) { 1178 intResult = (Integer ) m_rowcache.get(sKey); 1179 } 1180 1181 if(intResult == null) { 1182 intResult = new Integer (m_rs.getInt(n)); 1183 if(intResult != null) { 1184 m_rowcache.put(sKey, intResult); 1185 } 1186 } 1187 1188 return intResult.intValue(); 1189 } 1190 1191 1194 public short getShort(int arg0) throws SQLException { 1195 return m_rs.getShort(arg0); 1196 } 1197 1198 1201 public boolean getBoolean(int arg0) throws SQLException { 1202 return m_rs.getBoolean(arg0); 1203 } 1204 1205 1208 public float getFloat(String arg0) throws SQLException { 1209 return m_rs.getFloat(arg0); 1210 } 1211 1212 1215 public InputStream getBinaryStream(String arg0) throws SQLException { 1216 return m_rs.getBinaryStream(arg0); 1217 } 1218 1219 1222 public double getDouble(int arg0) throws SQLException { 1223 return m_rs.getDouble(arg0); 1224 } 1225 1226 1229 public byte getByte(String arg0) throws SQLException { 1230 return m_rs.getByte(arg0); 1231 } 1232 1233} | Popular Tags |