1 5 package org.h2.jdbc; 6 7 import java.io.InputStream ; 8 import java.io.Reader ; 9 import java.math.BigDecimal ; 10 import java.net.URL ; 11 import java.sql.*; 12 import java.util.Calendar ; 13 import java.util.Map ; 14 15 import org.h2.engine.Constants; 16 import org.h2.engine.SessionInterface; 17 import org.h2.message.*; 18 import org.h2.result.ResultInterface; 19 import org.h2.result.UpdatableRow; 20 import org.h2.util.ByteUtils; 21 import org.h2.util.DateTimeUtils; 22 import org.h2.util.IOUtils; 23 import org.h2.util.MathUtils; 24 import org.h2.util.StringUtils; 25 import org.h2.value.DataType; 26 import org.h2.value.Value; 27 import org.h2.value.ValueBoolean; 28 import org.h2.value.ValueByte; 29 import org.h2.value.ValueBytes; 30 import org.h2.value.ValueDate; 31 import org.h2.value.ValueDecimal; 32 import org.h2.value.ValueDouble; 33 import org.h2.value.ValueFloat; 34 import org.h2.value.ValueInt; 35 import org.h2.value.ValueLong; 36 import org.h2.value.ValueNull; 37 import org.h2.value.ValueShort; 38 import org.h2.value.ValueString; 39 import org.h2.value.ValueTime; 40 import org.h2.value.ValueTimestamp; 41 42 46 public class JdbcResultSet extends TraceObject implements ResultSet { 47 private SessionInterface session; 48 private ResultInterface result; 49 private JdbcConnection conn; 50 private JdbcStatement stat; 51 private int columnCount; 52 private boolean wasNull; 53 private Value[] insertRow; 54 private Value[] updateRow; 55 private boolean closeStatement; 56 57 62 public boolean next() throws SQLException { 63 try { 64 debugCodeCall("next"); 65 checkClosed(); 66 return result.next(); 67 } catch(Throwable e) { 68 throw logAndConvert(e); 69 } 70 } 71 72 77 public ResultSetMetaData getMetaData() throws SQLException { 78 try { 79 int id = getNextId(TraceObject.RESULT_SET_META_DATA); 80 if(debug()) { 81 debugCodeAssign("ResultSetMetaData", TraceObject.RESULT_SET_META_DATA, id); 82 debugCodeCall("getMetaData"); 83 } 84 checkClosed(); 85 JdbcResultSetMetaData meta = new JdbcResultSetMetaData(this, result, session.getTrace(), id); 86 return meta; 87 } catch(Throwable e) { 88 throw logAndConvert(e); 89 } 90 } 91 92 97 public boolean wasNull() throws SQLException { 98 try { 99 debugCodeCall("wasNull"); 100 checkClosed(); 101 return wasNull; 102 } catch(Throwable e) { 103 throw logAndConvert(e); 104 } 105 } 106 107 114 public int findColumn(String columnName) throws SQLException { 115 try { 116 debugCodeCall("findColumn", columnName); 117 return getColumnIndex(columnName); 118 } catch(Throwable e) { 119 throw logAndConvert(e); 120 } 121 } 122 123 126 public void close() throws SQLException { 127 try { 128 debugCodeCall("close"); 129 closeInternal(); 130 } catch(Throwable e) { 131 throw logAndConvert(e); 132 } 133 } 134 135 void closeInternal() throws SQLException { 136 if (result != null) { 137 try { 138 result.close(); 139 if(closeStatement && stat != null) { 140 stat.close(); 141 } 142 } finally { 143 columnCount = 0; 144 result = null; 145 stat = null; 146 conn = null; 147 insertRow = null; 148 updateRow = null; 149 } 150 } 151 } 152 153 158 public Statement getStatement() throws SQLException { 159 try { 160 debugCodeCall("getStatement"); 161 checkClosed(); 162 if(closeStatement) { 163 return null; 165 } 166 return stat; 167 } catch(Throwable e) { 168 throw logAndConvert(e); 169 } 170 } 171 172 177 public SQLWarning getWarnings() throws SQLException { 178 try { 179 debugCodeCall("getWarnings"); 180 checkClosed(); 181 return null; 182 } catch(Throwable e) { 183 throw logAndConvert(e); 184 } 185 } 186 187 190 public void clearWarnings() throws SQLException { 191 try { 192 debugCodeCall("clearWarnings"); 193 checkClosed(); 194 } catch(Throwable e) { 195 throw logAndConvert(e); 196 } 197 } 198 199 201 208 public String getString(int columnIndex) throws SQLException { 209 try { 210 debugCodeCall("getString", columnIndex); 211 return get(columnIndex).getString(); 212 } catch(Throwable e) { 213 throw logAndConvert(e); 214 } 215 } 216 217 224 public String getString(String columnName) throws SQLException { 225 try { 226 debugCodeCall("getString", columnName); 227 return get(columnName).getString(); 228 } catch(Throwable e) { 229 throw logAndConvert(e); 230 } 231 } 232 233 240 public int getInt(int columnIndex) throws SQLException { 241 try { 242 debugCodeCall("getInt", columnIndex); 243 return get(columnIndex).getInt(); 244 } catch(Throwable e) { 245 throw logAndConvert(e); 246 } 247 } 248 249 256 public int getInt(String columnName) throws SQLException { 257 try { 258 debugCodeCall("getInt", columnName); 259 return get(columnName).getInt(); 260 } catch(Throwable e) { 261 throw logAndConvert(e); 262 } 263 } 264 265 272 public BigDecimal getBigDecimal(int columnIndex) throws SQLException { 273 try { 274 debugCodeCall("getBigDecimal", columnIndex); 275 return get(columnIndex).getBigDecimal(); 276 } catch(Throwable e) { 277 throw logAndConvert(e); 278 } 279 } 280 281 288 public Date getDate(int columnIndex) throws SQLException { 289 try { 290 debugCodeCall("getDate", columnIndex); 291 return get(columnIndex).getDate(); 292 } catch(Throwable e) { 293 throw logAndConvert(e); 294 } 295 } 296 297 304 public Time getTime(int columnIndex) throws SQLException { 305 try { 306 debugCodeCall("getTime", columnIndex); 307 return get(columnIndex).getTime(); 308 } catch(Throwable e) { 309 throw logAndConvert(e); 310 } 311 } 312 313 320 public Timestamp getTimestamp(int columnIndex) throws SQLException { 321 try { 322 debugCodeCall("getTimestamp", columnIndex); 323 return get(columnIndex).getTimestamp(); 324 } catch(Throwable e) { 325 throw logAndConvert(e); 326 } 327 } 328 329 336 public BigDecimal getBigDecimal(String columnName) throws SQLException { 337 try { 338 debugCodeCall("getBigDecimal", columnName); 339 return get(columnName).getBigDecimal(); 340 } catch(Throwable e) { 341 throw logAndConvert(e); 342 } 343 } 344 345 352 public Date getDate(String columnName) throws SQLException { 353 try { 354 debugCodeCall("getDate", columnName); 355 return get(columnName).getDate(); 356 } catch(Throwable e) { 357 throw logAndConvert(e); 358 } 359 } 360 361 368 public Time getTime(String columnName) throws SQLException { 369 try { 370 debugCodeCall("getTime", columnName); 371 return get(columnName).getTime(); 372 } catch(Throwable e) { 373 throw logAndConvert(e); 374 } 375 } 376 377 384 public Timestamp getTimestamp(String columnName) throws SQLException { 385 try { 386 debugCodeCall("getTimestamp", columnName); 387 return get(columnName).getTimestamp(); 388 } catch(Throwable e) { 389 throw logAndConvert(e); 390 } 391 } 392 393 400 public Object getObject(int columnIndex) throws SQLException { 401 try { 402 debugCodeCall("getObject", columnIndex); 403 Value v = get(columnIndex); 404 if(Constants.SERIALIZE_JAVA_OBJECTS) { 405 if (v.getType() == Value.JAVA_OBJECT) { 406 return ByteUtils.deserialize(v.getBytesNoCopy()); 407 } 408 } 409 return v.getObject(); 410 } catch(Throwable e) { 411 throw logAndConvert(e); 412 } 413 } 414 415 422 public Object getObject(String columnName) throws SQLException { 423 try { 424 debugCodeCall("getObject", columnName); 425 Value v = get(columnName); 426 if(Constants.SERIALIZE_JAVA_OBJECTS) { 427 if (v.getType() == Value.JAVA_OBJECT) { 428 return ByteUtils.deserialize(v.getBytesNoCopy()); 429 } 430 } 431 return v.getObject(); 432 } catch(Throwable e) { 433 throw logAndConvert(e); 434 } 435 } 436 437 444 public boolean getBoolean(int columnIndex) throws SQLException { 445 try { 446 debugCodeCall("getBoolean", columnIndex); 447 Boolean v = get(columnIndex).getBoolean(); 448 return v == null ? false : v.booleanValue(); 449 } catch(Throwable e) { 450 throw logAndConvert(e); 451 } 452 } 453 454 461 public boolean getBoolean(String columnName) throws SQLException { 462 try { 463 debugCodeCall("getBoolean", columnName); 464 Boolean v = get(columnName).getBoolean(); 465 return v == null ? false : v.booleanValue(); 466 } catch(Throwable e) { 467 throw logAndConvert(e); 468 } 469 } 470 471 478 public byte getByte(int columnIndex) throws SQLException { 479 try { 480 debugCodeCall("getByte", columnIndex); 481 return get(columnIndex).getByte(); 482 } catch(Throwable e) { 483 throw logAndConvert(e); 484 } 485 } 486 487 494 public byte getByte(String columnName) throws SQLException { 495 try { 496 debugCodeCall("getByte", columnName); 497 return get(columnName).getByte(); 498 } catch(Throwable e) { 499 throw logAndConvert(e); 500 } 501 } 502 503 510 public short getShort(int columnIndex) throws SQLException { 511 try { 512 debugCodeCall("getShort", columnIndex); 513 return get(columnIndex).getShort(); 514 } catch(Throwable e) { 515 throw logAndConvert(e); 516 } 517 } 518 519 526 public short getShort(String columnName) throws SQLException { 527 try { 528 debugCodeCall("getShort", columnName); 529 return get(columnName).getShort(); 530 } catch(Throwable e) { 531 throw logAndConvert(e); 532 } 533 } 534 535 542 public long getLong(int columnIndex) throws SQLException { 543 try { 544 debugCodeCall("getLong", columnIndex); 545 return get(columnIndex).getLong(); 546 } catch(Throwable e) { 547 throw logAndConvert(e); 548 } 549 } 550 551 558 public long getLong(String columnName) throws SQLException { 559 try { 560 debugCodeCall("getLong", columnName); 561 return get(columnName).getLong(); 562 } catch(Throwable e) { 563 throw logAndConvert(e); 564 } 565 } 566 567 574 public float getFloat(int columnIndex) throws SQLException { 575 try { 576 debugCodeCall("getFloat", columnIndex); 577 return get(columnIndex).getFloat(); 578 } catch(Throwable e) { 579 throw logAndConvert(e); 580 } 581 } 582 583 590 public float getFloat(String columnName) throws SQLException { 591 try { 592 debugCodeCall("getFloat", columnName); 593 return get(columnName).getFloat(); 594 } catch(Throwable e) { 595 throw logAndConvert(e); 596 } 597 } 598 599 606 public double getDouble(int columnIndex) throws SQLException { 607 try { 608 debugCodeCall("getDouble", columnIndex); 609 return get(columnIndex).getDouble(); 610 } catch(Throwable e) { 611 throw logAndConvert(e); 612 } 613 } 614 615 622 public double getDouble(String columnName) throws SQLException { 623 try { 624 debugCodeCall("getDouble", columnName); 625 return get(columnName).getDouble(); 626 } catch(Throwable e) { 627 throw logAndConvert(e); 628 } 629 } 630 631 639 public BigDecimal getBigDecimal(String columnName, int scale) throws SQLException { 640 try { 641 if(debug()) { 642 debugCode("getBigDecimal(" + StringUtils.quoteJavaString(columnName)+", "+scale+");"); 643 } 644 if(scale < 0) { 645 throw Message.getInvalidValueException(""+scale, "scale"); 646 } 647 BigDecimal bd = get(columnName).getBigDecimal(); 648 return bd == null ? null : MathUtils.setScale(bd, scale); 649 } catch(Throwable e) { 650 throw logAndConvert(e); 651 } 652 } 653 654 662 public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { 663 try { 664 if(debug()) { 665 debugCode("getBigDecimal(" + columnIndex+", "+scale+");"); 666 } 667 if(scale < 0) { 668 throw Message.getInvalidValueException(""+scale, "scale"); 669 } 670 BigDecimal bd = get(columnIndex).getBigDecimal(); 671 return bd == null ? null : MathUtils.setScale(bd, scale); 672 } catch(Throwable e) { 673 throw logAndConvert(e); 674 } 675 } 676 677 683 public InputStream getUnicodeStream(int columnIndex) throws SQLException { 684 try { 685 debugCodeCall("getUnicodeStream", columnIndex); 686 throw Message.getUnsupportedException(); 687 } catch(Throwable e) { 688 throw logAndConvert(e); 689 } 690 } 691 692 698 public InputStream getUnicodeStream(String columnName) throws SQLException { 699 try { 700 debugCodeCall("getUnicodeStream", columnName); 701 throw Message.getUnsupportedException(); 702 } catch(Throwable e) { 703 throw logAndConvert(e); 704 } 705 } 706 707 712 public Object getObject(int columnIndex, Map map) throws SQLException { 713 try { 714 if(debug()) { 715 debugCode("getObject(" + columnIndex + ", map);"); 716 } 717 throw Message.getUnsupportedException(); 718 } catch(Throwable e) { 719 throw logAndConvert(e); 720 } 721 } 722 723 728 public Object getObject(String columnName, Map map) throws SQLException { 729 try { 730 if(debug()) { 731 debugCode("getObject(" + quote(columnName) + ", map);"); 732 } 733 throw Message.getUnsupportedException(); 734 } catch(Throwable e) { 735 throw logAndConvert(e); 736 } 737 } 738 739 744 public Ref getRef(int columnIndex) throws SQLException { 745 try { 746 debugCodeCall("getRef", columnIndex); 747 throw Message.getUnsupportedException(); 748 } catch(Throwable e) { 749 throw logAndConvert(e); 750 } 751 } 752 753 758 public Ref getRef(String columnName) throws SQLException { 759 try { 760 debugCodeCall("getRef", columnName); 761 throw Message.getUnsupportedException(); 762 } catch(Throwable e) { 763 throw logAndConvert(e); 764 } 765 } 766 767 775 public Date getDate(int columnIndex, Calendar calendar) throws SQLException { 776 try { 777 if(debug()) { 778 debugCode("getDate(" + columnIndex + ", calendar)"); 779 } 780 Date x = get(columnIndex).getDate(); 781 return DateTimeUtils.convertDateToCalendar(x, calendar); 782 } catch(Throwable e) { 783 throw logAndConvert(e); 784 } 785 } 786 787 795 public Date getDate(String columnName, Calendar calendar) throws SQLException { 796 try { 797 if(debug()) { 798 debugCode("getDate(" + StringUtils.quoteJavaString(columnName) + ", calendar)"); 799 } 800 Date x = get(columnName).getDate(); 801 return DateTimeUtils.convertDateToCalendar(x, calendar); 802 } catch(Throwable e) { 803 throw logAndConvert(e); 804 } 805 } 806 807 815 public Time getTime(int columnIndex, Calendar calendar) throws SQLException { 816 try { 817 if(debug()) { 818 debugCode("getTime(" + columnIndex + ", calendar)"); 819 } 820 Time x = get(columnIndex).getTime(); 821 return DateTimeUtils.convertTimeToCalendar(x, calendar); 822 } catch(Throwable e) { 823 throw logAndConvert(e); 824 } 825 } 826 827 835 public Time getTime(String columnName, Calendar calendar) throws SQLException { 836 try { 837 if(debug()) { 838 debugCode("getTime(" + StringUtils.quoteJavaString(columnName) + ", calendar)"); 839 } 840 Time x = get(columnName).getTime(); 841 return DateTimeUtils.convertTimeToCalendar(x, calendar); 842 } catch(Throwable e) { 843 throw logAndConvert(e); 844 } 845 } 846 847 855 public Timestamp getTimestamp(int columnIndex, Calendar calendar) throws SQLException { 856 try { 857 if(debug()) { 858 debugCode("getTimestamp(" + columnIndex + ", calendar)"); 859 } 860 Timestamp x = get(columnIndex).getTimestamp(); 861 return DateTimeUtils.convertTimestampToCalendar(x, calendar); 862 } catch(Throwable e) { 863 throw logAndConvert(e); 864 } 865 } 866 867 875 public Timestamp getTimestamp(String columnName, Calendar calendar) throws SQLException { 876 try { 877 if(debug()) { 878 debugCode("getTimestamp(" + StringUtils.quoteJavaString(columnName) + ", calendar)"); 879 } 880 Timestamp x = get(columnName).getTimestamp(); 881 return DateTimeUtils.convertTimestampToCalendar(x, calendar); 882 } catch(Throwable e) { 883 throw logAndConvert(e); 884 } 885 } 886 887 894 public Blob getBlob(int columnIndex) throws SQLException { 895 try { 896 int id = getNextId(TraceObject.BLOB); 897 debugCodeAssign("Blob", TraceObject.BLOB, id); 898 debugCodeCall("getBlob", columnIndex); 899 Value v = get(columnIndex); 900 return v == ValueNull.INSTANCE ? null : new JdbcBlob(session, conn, v, id); 901 } catch(Throwable e) { 902 throw logAndConvert(e); 903 } 904 } 905 906 913 public Blob getBlob(String columnName) throws SQLException { 914 try { 915 int id = getNextId(TraceObject.BLOB); 916 debugCodeAssign("Blob", TraceObject.BLOB, id); 917 debugCodeCall("getBlob", columnName); 918 Value v = get(columnName); 919 return v == ValueNull.INSTANCE ? null : new JdbcBlob(session, conn, v, id); 920 } catch(Throwable e) { 921 throw logAndConvert(e); 922 } 923 } 924 925 932 public byte[] getBytes(int columnIndex) throws SQLException { 933 try { 934 debugCodeCall("getBytes", columnIndex); 935 return get(columnIndex).getBytes(); 936 } catch(Throwable e) { 937 throw logAndConvert(e); 938 } 939 } 940 941 948 public byte[] getBytes(String columnName) throws SQLException { 949 try { 950 debugCodeCall("getBytes", columnName); 951 return get(columnName).getBytes(); 952 } catch(Throwable e) { 953 throw logAndConvert(e); 954 } 955 } 956 957 964 public InputStream getBinaryStream(int columnIndex) throws SQLException { 965 try { 966 debugCodeCall("getBinaryStream", columnIndex); 967 return get(columnIndex).getInputStream(); 968 } catch(Throwable e) { 969 throw logAndConvert(e); 970 } 971 } 972 973 980 public InputStream getBinaryStream(String columnName) throws SQLException { 981 try { 982 debugCodeCall("getBinaryStream", columnName); 983 return get(columnName).getInputStream(); 984 } catch(Throwable e) { 985 throw logAndConvert(e); 986 } 987 } 988 989 990 997 public Clob getClob(int columnIndex) throws SQLException { 998 try { 999 int id = getNextId(TraceObject.CLOB); 1000 debugCodeAssign("Clob", TraceObject.CLOB, id); 1001 debugCodeCall("getClob", columnIndex); 1002 Value v = get(columnIndex); 1003 return v == ValueNull.INSTANCE ? null : new JdbcClob(session, conn, v, id); 1004 } catch(Throwable e) { 1005 throw logAndConvert(e); 1006 } 1007 } 1008 1009 1016 public Clob getClob(String columnName) throws SQLException { 1017 try { 1018 int id = getNextId(TraceObject.CLOB); 1019 debugCodeAssign("Clob", TraceObject.CLOB, id); 1020 debugCodeCall("getClob", columnName); 1021 Value v = get(columnName); 1022 return v == ValueNull.INSTANCE ? null : new JdbcClob(session, conn, v, id); 1023 } catch(Throwable e) { 1024 throw logAndConvert(e); 1025 } 1026 } 1027 1028 1033 public Array getArray(int columnIndex) throws SQLException { 1034 try { 1035 debugCodeCall("getArray", columnIndex); 1036 throw Message.getUnsupportedException(); 1037 } catch(Throwable e) { 1038 throw logAndConvert(e); 1039 } 1040 } 1041 1042 1047 public Array getArray(String columnName) throws SQLException { 1048 try { 1049 debugCodeCall("getArray", columnName); 1050 throw Message.getUnsupportedException(); 1051 } catch(Throwable e) { 1052 throw logAndConvert(e); 1053 } 1054 } 1055 1056 1063 public InputStream getAsciiStream(int columnIndex) throws SQLException { 1064 try { 1065 debugCodeCall("getAsciiStream", columnIndex); 1066 String s = get(columnIndex).getString(); 1067 return s == null ? null : IOUtils.getInputStream(s); 1069 } catch(Throwable e) { 1070 throw logAndConvert(e); 1071 } 1072 } 1073 1074 1081 public InputStream getAsciiStream(String columnName) throws SQLException { 1082 try { 1083 debugCodeCall("getAsciiStream", columnName); 1084 String s = get(columnName).getString(); 1085 return IOUtils.getInputStream(s); 1087 } catch(Throwable e) { 1088 throw logAndConvert(e); 1089 } 1090 } 1091 1092 1099 public Reader getCharacterStream(int columnIndex) throws SQLException { 1100 try { 1101 debugCodeCall("getCharacterStream", columnIndex); 1102 return get(columnIndex).getReader(); 1103 } catch(Throwable e) { 1104 throw logAndConvert(e); 1105 } 1106 } 1107 1108 1115 public Reader getCharacterStream(String columnName) throws SQLException { 1116 try { 1117 debugCodeCall("getCharacterStream", columnName); 1118 return get(columnName).getReader(); 1119 } catch(Throwable e) { 1120 throw logAndConvert(e); 1121 } 1122 } 1123 1124 1129 public URL getURL(int columnIndex) throws SQLException { 1130 try { 1131 debugCodeCall("getURL", columnIndex); 1132 throw Message.getUnsupportedException(); 1133 } catch(Throwable e) { 1134 throw logAndConvert(e); 1135 } 1136 } 1137 1138 1143 public URL getURL(String columnName) throws SQLException { 1144 try { 1145 debugCodeCall("getURL", columnName); 1146 throw Message.getUnsupportedException(); 1147 } catch(Throwable e) { 1148 throw logAndConvert(e); 1149 } 1150 } 1151 1152 1154 1160 public void updateNull(int columnIndex) throws SQLException { 1161 try { 1162 debugCodeCall("updateNull", columnIndex); 1163 update(columnIndex, ValueNull.INSTANCE); 1164 } catch(Throwable e) { 1165 throw logAndConvert(e); 1166 } 1167 } 1168 1169 1175 public void updateNull(String columnName) throws SQLException { 1176 try { 1177 debugCodeCall("updateNull", columnName); 1178 update(columnName, ValueNull.INSTANCE); 1179 } catch(Throwable e) { 1180 throw logAndConvert(e); 1181 } 1182 } 1183 1184 1191 public void updateBoolean(int columnIndex, boolean x) throws SQLException { 1192 try { 1193 if(debug()) { 1194 debugCode("updateBoolean("+columnIndex+", "+x+");"); 1195 } 1196 update(columnIndex, ValueBoolean.get(x)); 1197 } catch(Throwable e) { 1198 throw logAndConvert(e); 1199 } 1200 } 1201 1202 1209 public void updateBoolean(String columnName, boolean x) throws SQLException { 1210 try { 1211 if(debug()) { 1212 debugCode("updateBoolean("+quote(columnName)+", "+x+");"); 1213 } 1214 update(columnName, ValueBoolean.get(x)); 1215 } catch(Throwable e) { 1216 throw logAndConvert(e); 1217 } 1218 } 1219 1220 1227 public void updateByte(int columnIndex, byte x) throws SQLException { 1228 try { 1229 if(debug()) { 1230 debugCode("updateByte("+columnIndex+", "+x+");"); 1231 } 1232 update(columnIndex, ValueByte.get(x)); 1233 } catch(Throwable e) { 1234 throw logAndConvert(e); 1235 } 1236 } 1237 1238 1245 public void updateByte(String columnName, byte x) throws SQLException { 1246 try { 1247 if(debug()) { 1248 debugCode("updateByte("+columnName+", "+x+");"); 1249 } 1250 update(columnName, ValueByte.get(x)); 1251 } catch(Throwable e) { 1252 throw logAndConvert(e); 1253 } 1254 } 1255 1256 1263 public void updateBytes(int columnIndex, byte[] x) throws SQLException { 1264 try { 1265 if(debug()) { 1266 debugCode("updateBytes("+columnIndex+", x);"); 1267 } 1268 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueBytes.get(x)); 1269 } catch(Throwable e) { 1270 throw logAndConvert(e); 1271 } 1272 } 1273 1274 1281 public void updateBytes(String columnName, byte[] x) throws SQLException { 1282 try { 1283 if(debug()) { 1284 debugCode("updateBytes("+quote(columnName)+", x);"); 1285 } 1286 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueBytes.get(x)); 1287 } catch(Throwable e) { 1288 throw logAndConvert(e); 1289 } 1290 } 1291 1292 1299 public void updateShort(int columnIndex, short x) throws SQLException { 1300 try { 1301 if(debug()) { 1302 debugCode("updateShort("+columnIndex+", "+x+");"); 1303 } 1304 update(columnIndex, ValueShort.get(x)); 1305 } catch(Throwable e) { 1306 throw logAndConvert(e); 1307 } 1308 } 1309 1310 1317 public void updateShort(String columnName, short x) throws SQLException { 1318 try { 1319 if(debug()) { 1320 debugCode("updateShort("+quote(columnName)+", "+x+");"); 1321 } 1322 update(columnName, ValueShort.get(x)); 1323 } catch(Throwable e) { 1324 throw logAndConvert(e); 1325 } 1326 } 1327 1328 1335 public void updateInt(int columnIndex, int x) throws SQLException { 1336 try { 1337 if(debug()) { 1338 debugCode("updateInt("+columnIndex+", "+x+");"); 1339 } 1340 update(columnIndex, ValueInt.get(x)); 1341 } catch(Throwable e) { 1342 throw logAndConvert(e); 1343 } 1344 } 1345 1346 1353 public void updateInt(String columnName, int x) throws SQLException { 1354 try { 1355 if(debug()) { 1356 debugCode("updateInt("+quote(columnName)+", "+x+");"); 1357 } 1358 update(columnName, ValueInt.get(x)); 1359 } catch(Throwable e) { 1360 throw logAndConvert(e); 1361 } 1362 } 1363 1364 1371 public void updateLong(int columnIndex, long x) throws SQLException { 1372 try { 1373 if(debug()) { 1374 debugCode("updateLong("+columnIndex+", "+x+");"); 1375 } 1376 update(columnIndex, ValueLong.get(x)); 1377 } catch(Throwable e) { 1378 throw logAndConvert(e); 1379 } 1380 } 1381 1382 1389 public void updateLong(String columnName, long x) throws SQLException { 1390 try { 1391 if(debug()) { 1392 debugCode("updateLong("+quote(columnName)+", "+x+");"); 1393 } 1394 update(columnName, ValueLong.get(x)); 1395 } catch(Throwable e) { 1396 throw logAndConvert(e); 1397 } 1398 } 1399 1400 1407 public void updateFloat(int columnIndex, float x) throws SQLException { 1408 try { 1409 if(debug()) { 1410 debugCode("updateFloat("+columnIndex+", "+x+"f);"); 1411 } 1412 update(columnIndex, ValueFloat.get(x)); 1413 } catch(Throwable e) { 1414 throw logAndConvert(e); 1415 } 1416 } 1417 1418 1425 public void updateFloat(String columnName, float x) throws SQLException { 1426 try { 1427 if(debug()) { 1428 debugCode("updateFloat("+quote(columnName)+", "+x+"f);"); 1429 } 1430 update(columnName, ValueFloat.get(x)); 1431 } catch(Throwable e) { 1432 throw logAndConvert(e); 1433 } 1434 } 1435 1436 1443 public void updateDouble(int columnIndex, double x) throws SQLException { 1444 try { 1445 if(debug()) { 1446 debugCode("updateDouble("+columnIndex+", "+x+");"); 1447 } 1448 update(columnIndex, ValueDouble.get(x)); 1449 } catch(Throwable e) { 1450 throw logAndConvert(e); 1451 } 1452 } 1453 1454 1461 public void updateDouble(String columnName, double x) throws SQLException { 1462 try { 1463 if(debug()) { 1464 debugCode("updateDouble("+quote(columnName)+", "+x+");"); 1465 } 1466 update(columnName, ValueDouble.get(x)); 1467 } catch(Throwable e) { 1468 throw logAndConvert(e); 1469 } 1470 } 1471 1472 1479 public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { 1480 try { 1481 if(debug()) { 1482 debugCode("updateBigDecimal("+columnIndex+", x);"); 1483 } 1484 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueDecimal.get(x)); 1485 } catch(Throwable e) { 1486 throw logAndConvert(e); 1487 } 1488 } 1489 1490 1497 public void updateBigDecimal(String columnName, BigDecimal x) throws SQLException { 1498 try { 1499 if(debug()) { 1500 debugCode("updateBigDecimal("+quote(columnName)+", x);"); 1501 } 1502 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueDecimal.get(x)); 1503 } catch(Throwable e) { 1504 throw logAndConvert(e); 1505 } 1506 } 1507 1508 1515 public void updateString(int columnIndex, String x) throws SQLException { 1516 try { 1517 if(debug()) { 1518 debugCode("updateString("+columnIndex+", "+quote(x)+");"); 1519 } 1520 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueString.get(x)); 1521 } catch(Throwable e) { 1522 throw logAndConvert(e); 1523 } 1524 } 1525 1526 1533 public void updateString(String columnName, String x) throws SQLException { 1534 try { 1535 if(debug()) { 1536 debugCode("updateString("+quote(columnName)+", "+quote(x)+");"); 1537 } 1538 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueString.get(x)); 1539 } catch(Throwable e) { 1540 throw logAndConvert(e); 1541 } 1542 } 1543 1544 1551 public void updateDate(int columnIndex, Date x) throws SQLException { 1552 try { 1553 if(debug()) { 1554 debugCode("updateDate("+columnIndex+", x);"); 1555 } 1556 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueDate.get(x)); 1557 } catch(Throwable e) { 1558 throw logAndConvert(e); 1559 } 1560 } 1561 1562 1569 public void updateDate(String columnName, Date x) throws SQLException { 1570 try { 1571 if(debug()) { 1572 debugCode("updateDate("+quote(columnName)+", x);"); 1573 } 1574 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueDate.get(x)); 1575 } catch(Throwable e) { 1576 throw logAndConvert(e); 1577 } 1578 } 1579 1580 1587 public void updateTime(int columnIndex, Time x) throws SQLException { 1588 try { 1589 if(debug()) { 1590 debugCode("updateTime("+columnIndex+", x);"); 1591 } 1592 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x)); 1593 } catch(Throwable e) { 1594 throw logAndConvert(e); 1595 } 1596 } 1597 1598 1605 public void updateTime(String columnName, Time x) throws SQLException { 1606 try { 1607 if(debug()) { 1608 debugCode("updateTime("+quote(columnName)+", x);"); 1609 } 1610 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTime.get(x)); 1611 } catch(Throwable e) { 1612 throw logAndConvert(e); 1613 } 1614 } 1615 1616 1623 public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { 1624 try { 1625 if(debug()) { 1626 debugCode("updateTimestamp("+columnIndex+", x);"); 1627 } 1628 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(x)); 1629 } catch(Throwable e) { 1630 throw logAndConvert(e); 1631 } 1632 } 1633 1634 1641 public void updateTimestamp(String columnName, Timestamp x) throws SQLException { 1642 try { 1643 if(debug()) { 1644 debugCode("updateTimestamp("+quote(columnName)+", x);"); 1645 } 1646 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueTimestamp.get(x)); 1647 } catch(Throwable e) { 1648 throw logAndConvert(e); 1649 } 1650 } 1651 1652 1660 public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { 1661 updateAsciiStream(columnIndex, x, (long) length); 1662 } 1663 1664 1672 public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { 1673 updateAsciiStream(columnIndex, x, -1); 1674 } 1675 1676 1684 public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { 1685 try { 1686 if(debug()) { 1687 debugCode("updateAsciiStream("+columnIndex+", x, "+length+");"); 1688 } 1689 checkClosed(); 1690 Value v = conn.createClob(IOUtils.getAsciiReader(x), length); 1691 update(columnIndex, v); 1692 } catch(Throwable e) { 1693 throw logAndConvert(e); 1694 } 1695 } 1696 1697 1705 public void updateAsciiStream(String columnName, InputStream x, int length) throws SQLException { 1706 updateAsciiStream(columnName, x, (long) length); 1707 } 1708 1709 1717 public void updateAsciiStream(String columnName, InputStream x) throws SQLException { 1718 updateAsciiStream(columnName, x, -1); 1719 } 1720 1721 1729 public void updateAsciiStream(String columnName, InputStream x, long length) throws SQLException { 1730 try { 1731 if(debug()) { 1732 debugCode("updateAsciiStream("+quote(columnName)+", x, "+length+");"); 1733 } 1734 checkClosed(); 1735 Value v = conn.createClob(IOUtils.getAsciiReader(x), length); 1736 update(columnName, v); 1737 } catch(Throwable e) { 1738 throw logAndConvert(e); 1739 } 1740 } 1741 1742 1750 public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { 1751 updateBinaryStream(columnIndex, x, (long) length); 1752 } 1753 1754 1761 public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { 1762 updateBinaryStream(columnIndex, x, -1); 1763 } 1764 1765 1773 public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException { 1774 try { 1775 if(debug()) { 1776 debugCode("updateBinaryStream("+columnIndex+", x, "+length+");"); 1777 } 1778 checkClosed(); 1779 Value v = conn.createBlob(x, length); 1780 update(columnIndex, v); 1781 } catch(Throwable e) { 1782 throw logAndConvert(e); 1783 } 1784 } 1785 1786 1793 public void updateBinaryStream(String columnName, InputStream x) throws SQLException { 1794 updateBinaryStream(columnName, x, -1); 1795 } 1796 1797 1805 public void updateBinaryStream(String columnName, InputStream x, int length) throws SQLException { 1806 updateBinaryStream(columnName, x, (long) length); 1807 } 1808 1809 1817 public void updateBinaryStream(String columnName, InputStream x, long length) throws SQLException { 1818 try { 1819 if(debug()) { 1820 debugCode("updateBinaryStream("+quote(columnName)+", x, "+length+");"); 1821 } 1822 checkClosed(); 1823 Value v = conn.createBlob(x, length); 1824 update(columnName, v); 1825 } catch(Throwable e) { 1826 throw logAndConvert(e); 1827 } 1828 } 1829 1830 1838 public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { 1839 try { 1840 if(debug()) { 1841 debugCode("updateCharacterStream("+columnIndex+", x, "+length+");"); 1842 } 1843 checkClosed(); 1844 Value v = conn.createClob(x, length); 1845 update(columnIndex, v); 1846 } catch(Throwable e) { 1847 throw logAndConvert(e); 1848 } 1849 } 1850 1851 1859 public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { 1860 updateCharacterStream(columnIndex, x, (long) length); 1861 } 1862 1863 1870 public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { 1871 updateCharacterStream(columnIndex, x, -1); 1872 } 1873 1874 1882 public void updateCharacterStream(String columnName, Reader x, int length) throws SQLException { 1883 updateCharacterStream(columnName, x, (long) length); 1884 } 1885 1886 1893 public void updateCharacterStream(String columnName, Reader x) throws SQLException { 1894 updateCharacterStream(columnName, x, -1); 1895 } 1896 1897 1905 public void updateCharacterStream(String columnName, Reader x, long length) throws SQLException { 1906 try { 1907 if(debug()) { 1908 debugCode("updateCharacterStream("+quote(columnName)+", x, "+length+");"); 1909 } 1910 checkClosed(); 1911 Value v = conn.createClob(x, length); 1912 update(columnName, v); 1913 } catch(Throwable e) { 1914 throw logAndConvert(e); 1915 } 1916 } 1917 1918 1926 public void updateObject(int columnIndex, Object x, int scale) throws SQLException { 1927 try { 1928 if(debug()) { 1929 debugCode("updateObject("+columnIndex+", x, "+scale+");"); 1930 } 1931 update(columnIndex, DataType.convertToValue(session, x, Value.UNKNOWN)); 1932 } catch(Throwable e) { 1933 throw logAndConvert(e); 1934 } 1935 } 1936 1937 1945 public void updateObject(String columnName, Object x, int scale) throws SQLException { 1946 try { 1947 if(debug()) { 1948 debugCode("updateObject("+quote(columnName)+", x, "+scale+");"); 1949 } 1950 update(columnName, DataType.convertToValue(session, x, Value.UNKNOWN)); 1951 } catch(Throwable e) { 1952 throw logAndConvert(e); 1953 } 1954 } 1955 1956 1963 public void updateObject(int columnIndex, Object x) throws SQLException { 1964 try { 1965 if(debug()) { 1966 debugCode("updateObject("+columnIndex+", x);"); 1967 } 1968 update(columnIndex, DataType.convertToValue(session, x, Value.UNKNOWN)); 1969 } catch(Throwable e) { 1970 throw logAndConvert(e); 1971 } 1972 } 1973 1974 1981 public void updateObject(String columnName, Object x) throws SQLException { 1982 try { 1983 if(debug()) { 1984 debugCode("updateObject("+quote(columnName)+", x);"); 1985 } 1986 update(columnName, DataType.convertToValue(session, x, Value.UNKNOWN)); 1987 } catch(Throwable e) { 1988 throw logAndConvert(e); 1989 } 1990 } 1991 1992 1997 public void updateRef(int columnIndex, Ref x) throws SQLException { 1998 try { 1999 if(debug()) { 2000 debugCode("updateRef("+columnIndex+", x);"); 2001 } 2002 throw Message.getUnsupportedException(); 2003 } catch(Throwable e) { 2004 throw logAndConvert(e); 2005 } 2006 } 2007 2008 2013 public void updateRef(String columnName, Ref x) throws SQLException { 2014 try { 2015 if(debug()) { 2016 debugCode("updateRef("+quote(columnName)+", x);"); 2017 } 2018 throw Message.getUnsupportedException(); 2019 } catch(Throwable e) { 2020 throw logAndConvert(e); 2021 } 2022 } 2023 2024 2031 public void updateBlob(int columnIndex, InputStream x) throws SQLException { 2032 updateBlob(columnIndex, x, -1); 2033 } 2034 2035 2043 public void updateBlob(int columnIndex, InputStream x, long length) throws SQLException { 2044 try { 2045 if(debug()) { 2046 debugCode("updateBlob("+columnIndex+", x, " + length + ");"); 2047 } 2048 Value v = conn.createBlob(x, length); 2049 update(columnIndex, v); 2050 } catch(Throwable e) { 2051 throw logAndConvert(e); 2052 } 2053 } 2054 2055 2062 public void updateBlob(int columnIndex, Blob x) throws SQLException { 2063 try { 2064 if(debug()) { 2065 debugCode("updateBlob("+columnIndex+", x);"); 2066 } 2067 Value v; 2068 if(x == null) { 2069 v = ValueNull.INSTANCE; 2070 } else { 2071 v = conn.createBlob(x.getBinaryStream(), -1); 2072 } 2073 update(columnIndex, v); 2074 } catch(Throwable e) { 2075 throw logAndConvert(e); 2076 } 2077 } 2078 2079 2086 public void updateBlob(String columnName, Blob x) throws SQLException { 2087 try { 2088 if(debug()) { 2089 debugCode("updateBlob("+quote(columnName)+", x);"); 2090 } 2091 Value v; 2092 if(x == null) { 2093 v = ValueNull.INSTANCE; 2094 } else { 2095 v = conn.createBlob(x.getBinaryStream(), -1); 2096 } 2097 update(columnName, v); 2098 } catch(Throwable e) { 2099 throw logAndConvert(e); 2100 } 2101 } 2102 2103 2110 public void updateBlob(String columnName, InputStream x) throws SQLException { 2111 updateBlob(columnName, x, -1); 2112 } 2113 2114 2122 public void updateBlob(String columnName, InputStream x, long length) throws SQLException { 2123 try { 2124 if(debug()) { 2125 debugCode("updateBlob("+quote(columnName)+", x, " + length + ");"); 2126 } 2127 Value v = conn.createBlob(x, -1); 2128 update(columnName, v); 2129 } catch(Throwable e) { 2130 throw logAndConvert(e); 2131 } 2132 } 2133 2134 2141 public void updateClob(int columnIndex, Clob x) throws SQLException { 2142 try { 2143 if(debug()) { 2144 debugCode("updateClob("+columnIndex+", x);"); 2145 } 2146 checkClosed(); 2147 Value v; 2148 if(x == null) { 2149 v = ValueNull.INSTANCE; 2150 } else { 2151 v = conn.createClob(x.getCharacterStream(), -1); 2152 } 2153 update(columnIndex, v); 2154 } catch(Throwable e) { 2155 throw logAndConvert(e); 2156 } 2157 } 2158 2159 2166 public void updateClob(int columnIndex, Reader x) throws SQLException { 2167 updateClob(columnIndex, x, -1); 2168 } 2169 2170 2178 public void updateClob(int columnIndex, Reader x, long length) throws SQLException { 2179 try { 2180 if(debug()) { 2181 debugCode("updateClob("+columnIndex+", x, " + length + ");"); 2182 } 2183 checkClosed(); 2184 Value v = conn.createClob(x, length); 2185 update(columnIndex, v); 2186 } catch(Throwable e) { 2187 throw logAndConvert(e); 2188 } 2189 } 2190 2191 2198 public void updateClob(String columnName, Clob x) throws SQLException { 2199 try { 2200 if(debug()) { 2201 debugCode("updateClob("+quote(columnName)+", x);"); 2202 } 2203 checkClosed(); 2204 Value v; 2205 if(x == null) { 2206 v = ValueNull.INSTANCE; 2207 } else { 2208 v = conn.createClob(x.getCharacterStream(), -1); 2209 } 2210 update(columnName, v); 2211 } catch(Throwable e) { 2212 throw logAndConvert(e); 2213 } 2214 } 2215 2216 2223 public void updateClob(String columnName, Reader x) throws SQLException { 2224 updateClob(columnName, x, -1); 2225 } 2226 2227 2235 public void updateClob(String columnName, Reader x, long length) throws SQLException { 2236 try { 2237 if(debug()) { 2238 debugCode("updateClob("+quote(columnName)+", x);"); 2239 } 2240 checkClosed(); 2241 Value v = conn.createClob(x, length); 2242 update(columnName, v); 2243 } catch(Throwable e) { 2244 throw logAndConvert(e); 2245 } 2246 } 2247 2248 2253 public void updateArray(int columnIndex, Array x) throws SQLException { 2254 try { 2255 if(debug()) { 2256 debugCode("updateArray("+columnIndex+", x);"); 2257 } 2258 throw Message.getUnsupportedException(); 2259 } catch(Throwable e) { 2260 throw logAndConvert(e); 2261 } 2262 } 2263 2264 2269 public void updateArray(String columnName, Array x) throws SQLException { 2270 try { 2271 if(debug()) { 2272 debugCode("updateArray("+quote(columnName)+", x);"); 2273 } 2274 throw Message.getUnsupportedException(); 2275 } catch(Throwable e) { 2276 throw logAndConvert(e); 2277 } 2278 } 2279 2280 2287 public String getCursorName() throws SQLException { 2288 try { 2289 debugCodeCall("getCursorName"); 2290 throw Message.getUnsupportedException(); 2291 } catch(Throwable e) { 2292 throw logAndConvert(e); 2293 } 2294 } 2295 2296 2302 public int getRow() throws SQLException { 2303 try { 2304 debugCodeCall("getRow"); 2305 checkClosed(); 2306 int rowId = result.getRowId(); 2307 if (rowId >= result.getRowCount()) { 2308 return 0; 2309 } else { 2310 return rowId + 1; 2311 } 2312 } catch(Throwable e) { 2313 throw logAndConvert(e); 2314 } 2315 } 2316 2317 2322 public int getConcurrency() throws SQLException { 2323 try { 2324 debugCodeCall("getConcurrency"); 2325 checkClosed(); 2326 UpdatableRow upd = new UpdatableRow(conn, result, session); 2327 return upd.isUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY; 2328 } catch(Throwable e) { 2329 throw logAndConvert(e); 2330 } 2331 } 2332 2333 2338 public int getFetchDirection() throws SQLException { 2339 try { 2340 debugCodeCall("getFetchDirection"); 2341 checkClosed(); 2342 return ResultSet.FETCH_FORWARD; 2343 } catch(Throwable e) { 2344 throw logAndConvert(e); 2345 } 2346 } 2347 2348 2353 public int getFetchSize() throws SQLException { 2354 try { 2355 debugCodeCall("getFetchSize"); 2356 checkClosed(); 2357 return 0; 2358 } catch(Throwable e) { 2359 throw logAndConvert(e); 2360 } 2361 } 2362 2363 2369 public void setFetchSize(int rowCount) throws SQLException { 2370 try { 2371 debugCodeCall("setFetchSize", rowCount); 2372 checkClosed(); 2373 if (rowCount < 0) { 2374 throw Message.getInvalidValueException("" + rowCount, "rowCount"); 2375 } 2376 if (rowCount > 0) { 2377 if (stat != null) { 2378 int maxRows = stat.getMaxRows(); 2379 if (maxRows > 0 && rowCount > maxRows) { 2380 throw Message.getInvalidValueException("" + rowCount, "rowCount"); 2381 } 2382 } 2383 } 2384 } catch(Throwable e) { 2385 throw logAndConvert(e); 2386 } 2387 } 2388 2389 2396 public void setFetchDirection(int direction) throws SQLException { 2397 try { 2398 debugCodeCall("setFetchDirection", direction); 2399 throw Message.getUnsupportedException(); 2400 } catch(Throwable e) { 2401 throw logAndConvert(e); 2402 } 2403 } 2404 2405 2411 public int getType() throws SQLException { 2412 try { 2413 debugCodeCall("getType"); 2414 checkClosed(); 2415 return stat == null ? ResultSet.TYPE_FORWARD_ONLY : stat.resultSetType; 2416 } catch(Throwable e) { 2417 throw logAndConvert(e); 2418 } 2419 } 2420 2421 2427 public boolean isBeforeFirst() throws SQLException { 2428 try { 2429 debugCodeCall("isBeforeFirst"); 2430 checkClosed(); 2431 return result.getRowId() < 0; 2432 } catch(Throwable e) { 2433 throw logAndConvert(e); 2434 } 2435 } 2436 2437 2443 public boolean isAfterLast() throws SQLException { 2444 try { 2445 debugCodeCall("isAfterLast"); 2446 checkClosed(); 2447 int row = result.getRowId(); 2448 int count = result.getRowCount(); 2449 return row >= count || count == 0; 2450 } catch(Throwable e) { 2451 throw logAndConvert(e); 2452 } 2453 } 2454 2455 2461 public boolean isFirst() throws SQLException { 2462 try { 2463 debugCodeCall("isFirst"); 2464 checkClosed(); 2465 int row = result.getRowId(); 2466 return row == 0 && row < result.getRowCount(); 2467 } catch(Throwable e) { 2468 throw logAndConvert(e); 2469 } 2470 } 2471 2472 2479 public boolean isLast() throws SQLException { 2480 try { 2481 debugCodeCall("isLast"); 2482 checkClosed(); 2483 int row = result.getRowId(); 2484 return row >= 0 && row == result.getRowCount() - 1; 2485 } catch(Throwable e) { 2486 throw logAndConvert(e); 2487 } 2488 } 2489 2490 2495 public void beforeFirst() throws SQLException { 2496 try { 2497 debugCodeCall("beforeFirst"); 2498 checkClosed(); 2499 result.reset(); 2500 } catch(Throwable e) { 2501 throw logAndConvert(e); 2502 } 2503 } 2504 2505 2510 public void afterLast() throws SQLException { 2511 try { 2512 debugCodeCall("afterLast"); 2513 checkClosed(); 2514 while (result.next()) { 2515 } 2517 } catch(Throwable e) { 2518 throw logAndConvert(e); 2519 } 2520} 2521 2522 2528 public boolean first() throws SQLException { 2529 try { 2530 debugCodeCall("first"); 2531 checkClosed(); 2532 result.reset(); 2533 return result.next(); 2534 } catch(Throwable e) { 2535 throw logAndConvert(e); 2536 } 2537 } 2538 2539 2545 public boolean last() throws SQLException { 2546 try { 2547 debugCodeCall("last"); 2548 checkClosed(); 2549 return absolute(-1); 2550 } catch(Throwable e) { 2551 throw logAndConvert(e); 2552 } 2553 } 2554 2555 2564 public boolean absolute(int rowNumber) throws SQLException { 2565 try { 2566 debugCodeCall("absolute", rowNumber); 2567 checkClosed(); 2568 if (rowNumber < 0) { 2569 rowNumber = result.getRowCount() + rowNumber + 1; 2570 } else if (rowNumber > result.getRowCount() + 1) { 2571 rowNumber = result.getRowCount() + 1; 2572 } 2573 if (rowNumber <= result.getRowId()) { 2577 result.reset(); 2578 } 2579 while (result.getRowId() + 1 < rowNumber) { 2580 result.next(); 2581 } 2582 int row = result.getRowId(); 2583 return row >= 0 && row < result.getRowCount(); 2584 } catch(Throwable e) { 2585 throw logAndConvert(e); 2586 } 2587 } 2588 2589 2598 public boolean relative(int rowCount) throws SQLException { 2599 try { 2600 debugCodeCall("relative", rowCount); 2601 checkClosed(); 2602 int row = result.getRowId() + 1 + rowCount; 2603 if (row < 0) { 2604 row = 0; 2605 } else if (row > result.getRowCount()) { 2606 row = result.getRowCount() + 1; 2607 } 2608 return absolute(row); 2609 } catch(Throwable e) { 2610 throw logAndConvert(e); 2611 } 2612 } 2613 2614 2620 public boolean previous() throws SQLException { 2621 try { 2622 debugCodeCall("previous"); 2623 checkClosed(); 2624 return relative(-1); 2625 } catch(Throwable e) { 2626 throw logAndConvert(e); 2627 } 2628 } 2629 2630 2635 public void moveToInsertRow() throws SQLException { 2636 try { 2637 debugCodeCall("moveToInsertRow"); 2638 checkClosed(); 2639 insertRow = new Value[columnCount]; 2640 } catch(Throwable e) { 2641 throw logAndConvert(e); 2642 } 2643 } 2644 2645 2650 public void moveToCurrentRow() throws SQLException { 2651 try { 2652 debugCodeCall("moveToCurrentRow"); 2653 checkClosed(); 2654 insertRow = null; 2655 } catch(Throwable e) { 2656 throw logAndConvert(e); 2657 } 2658 } 2659 2660 2665 public boolean rowUpdated() throws SQLException { 2666 try { 2667 debugCodeCall("rowUpdated"); 2668 return false; 2669 } catch(Throwable e) { 2670 throw logAndConvert(e); 2671 } 2672 } 2673 2674 2679 public boolean rowInserted() throws SQLException { 2680 try { 2681 debugCodeCall("rowInserted"); 2682 return false; 2683 } catch(Throwable e) { 2684 throw logAndConvert(e); 2685 } 2686 } 2687 2688 2693 public boolean rowDeleted() throws SQLException { 2694 try { 2695 debugCodeCall("rowDeleted"); 2696 return false; 2697 } catch(Throwable e) { 2698 throw logAndConvert(e); 2699 } 2700 } 2701 2702 2707 public void insertRow() throws SQLException { 2708 try { 2709 debugCodeCall("insertRow"); 2710 checkClosed(); 2711 if (insertRow == null) { 2712 throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW); 2713 } 2714 getUpdatableRow().insertRow(insertRow); 2715 insertRow = null; 2716 } catch(Throwable e) { 2717 throw logAndConvert(e); 2718 } 2719 } 2720 2721 2726 public void updateRow() throws SQLException { 2727 try { 2728 debugCodeCall("updateRow"); 2729 checkClosed(); 2730 if (insertRow != null) { 2731 throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW); 2732 } 2733 checkOnValidRow(); 2734 if (updateRow != null) { 2735 getUpdatableRow().updateRow(result.currentRow(), updateRow); 2736 updateRow = null; 2737 } 2738 } catch(Throwable e) { 2739 throw logAndConvert(e); 2740 } 2741 } 2742 2743 2748 public void deleteRow() throws SQLException { 2749 try { 2750 debugCodeCall("deleteRow"); 2751 checkClosed(); 2752 if (insertRow != null) { 2753 throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW); 2754 } 2755 checkOnValidRow(); 2756 getUpdatableRow().deleteRow(result.currentRow()); 2757 updateRow = null; 2758 } catch(Throwable e) { 2759 throw logAndConvert(e); 2760 } 2761 } 2762 2763 2769 public void refreshRow() throws SQLException { 2770 try { 2771 debugCodeCall("refreshRow"); 2772 checkClosed(); 2773 if (insertRow != null) { 2774 throw Message.getSQLException(Message.NO_DATA_AVAILABLE); 2775 } 2776 checkOnValidRow(); 2777 getUpdatableRow().refreshRow(result.currentRow()); 2778 updateRow = null; 2779 } catch(Throwable e) { 2780 throw logAndConvert(e); 2781 } 2782 } 2783 2784 2789 public void cancelRowUpdates() throws SQLException { 2790 try { 2791 debugCodeCall("cancelRowUpdates"); 2792 checkClosed(); 2793 if (insertRow != null) { 2794 throw Message.getSQLException(Message.NO_DATA_AVAILABLE); 2795 } 2796 updateRow = null; 2797 } catch(Throwable e) { 2798 throw logAndConvert(e); 2799 } 2800 } 2801 2802 2804 JdbcResultSet(SessionInterface session, JdbcConnection conn, JdbcStatement stat, ResultInterface result, int id, boolean closeStatement) { 2805 setTrace(session.getTrace(), TraceObject.RESULT_SET, id); 2806 this.session = session; 2807 this.conn = conn; 2808 this.stat = stat; 2809 this.result = result; 2810 columnCount = result.getVisibleColumnCount(); 2811 this.closeStatement = closeStatement; 2812 } 2813 2814 private UpdatableRow getUpdatableRow() throws SQLException { 2815 UpdatableRow upd = new UpdatableRow(conn, result, session); 2816 if(!upd.isUpdatable()) { 2817 throw Message.getSQLException(Message.NOT_ON_UPDATABLE_ROW); 2818 } 2819 return upd; 2820 } 2821 2822 int getColumnIndex(String columnName) throws SQLException { 2823 checkClosed(); 2824 if (columnName == null) { 2825 throw Message.getInvalidValueException("columnName", null); 2826 } 2827 for (int i = 0; i < columnCount; i++) { 2828 if (columnName.equalsIgnoreCase(result.getAlias(i))) { 2829 return i + 1; 2830 } 2831 } 2832 int idx = columnName.indexOf('.'); 2833 if(idx > 0) { 2834 String table = columnName.substring(0, idx); 2835 String col = columnName.substring(idx+1); 2836 for (int i = 0; i < columnCount; i++) { 2837 if (table.equals(result.getTableName(i)) && col.equalsIgnoreCase(result.getColumnName(i))) { 2838 return i + 1; 2839 } 2840 } 2841 } 2842 throw Message.getSQLException(Message.COLUMN_NOT_FOUND_1, columnName); 2843 } 2844 2845 void checkColumnIndex(int columnIndex) throws SQLException { 2846 checkClosed(); 2847 if (columnIndex < 1 || columnIndex > columnCount) { 2848 throw Message.getInvalidValueException("" + columnIndex, "columnIndex"); 2849 } 2850 } 2851 2852 void checkClosed() throws SQLException { 2853 if (result == null) { 2854 throw Message.getSQLException(Message.OBJECT_CLOSED); 2855 } 2856 if (stat != null) { 2857 stat.checkClosed(); 2858 } 2859 if(conn != null) { 2860 conn.checkClosed(); 2861 } 2862 } 2863 2864 private void checkOnValidRow() throws SQLException { 2865 if (result.getRowId() < 0 || result.getRowId() >= result.getRowCount()) { 2866 throw Message.getSQLException(Message.NO_DATA_AVAILABLE); 2867 } 2868 } 2869 2870 private Value get(int columnIndex) throws SQLException { 2871 checkColumnIndex(columnIndex); 2872 checkOnValidRow(); 2873 Value[] list = result.currentRow(); 2874 Value value = list[columnIndex - 1]; 2875 wasNull = value == ValueNull.INSTANCE; 2876 return value; 2877 } 2878 2879 private Value get(String columnName) throws SQLException { 2880 int columnIndex = getColumnIndex(columnName); 2881 return get(columnIndex); 2882 } 2883 2884 private void update(String columnName, Value v) throws SQLException { 2885 int columnIndex = getColumnIndex(columnName); 2886 update(columnIndex, v); 2887 } 2888 2889 private void update(int columnIndex, Value v) throws SQLException { 2890 checkColumnIndex(columnIndex); 2891 if (insertRow != null) { 2892 insertRow[columnIndex - 1] = v; 2893 } else { 2894 if (updateRow == null) { 2895 updateRow = new Value[columnCount]; 2896 } 2897 updateRow[columnIndex - 1] = v; 2898 } 2899 } 2900 2901 2904 public int getTraceId() { 2905 return super.getTraceId(); 2906 } 2907 2908 JdbcConnection getConnection() { 2909 return conn; 2910 } 2911 2912 2916 2922 2924 2928 2934 2936 2940 2946 2948 2952 2958 2960 2966 public int getHoldability() throws SQLException { 2967 try { 2968 debugCodeCall("getHoldability"); 2969 return conn.getHoldability(); 2970 } catch(Throwable e) { 2971 throw logAndConvert(e); 2972 } 2973 } 2974 2975 2980 public boolean isClosed() throws SQLException { 2981 try { 2982 debugCodeCall("isClosed"); 2983 return result == null; 2984 } catch(Throwable e) { 2985 throw logAndConvert(e); 2986 } 2987 } 2988 2989 2996 public void updateNString(int columnIndex, String x) throws SQLException { 2997 try { 2998 if(debug()) { 2999 debugCode("updateNString("+columnIndex+", "+quote(x)+");"); 3000 } 3001 update(columnIndex, x == null ? (Value) ValueNull.INSTANCE : ValueString.get(x)); 3002 } catch(Throwable e) { 3003 throw logAndConvert(e); 3004 } 3005 } 3006 3007 3014 public void updateNString(String columnName, String x) throws SQLException { 3015 try { 3016 if(debug()) { 3017 debugCode("updateNString("+quote(columnName)+", "+quote(x)+");"); 3018 } 3019 update(columnName, x == null ? (Value) ValueNull.INSTANCE : ValueString.get(x)); 3020 } catch(Throwable e) { 3021 throw logAndConvert(e); 3022 } 3023 } 3024 3025 3030 3043 3045 3050 3063 3065 3070 3083 3085 3090 3103 3105 3110 3123 3125 3130 3143 3145 3146 3153 3167 3169 3176 3190 3192 3196 3202 3204 3208 3214 3216 3220 3226 3228 3232 3238 3240 3247 public String getNString(int columnIndex) throws SQLException { 3248 try { 3249 debugCodeCall("getNString", columnIndex); 3250 return get(columnIndex).getString(); 3251 } catch(Throwable e) { 3252 throw logAndConvert(e); 3253 } 3254 } 3255 3256 3263 public String getNString(String columnName) throws SQLException { 3264 try { 3265 debugCodeCall("getNString", columnName); 3266 return get(columnName).getString(); 3267 } catch(Throwable e) { 3268 throw logAndConvert(e); 3269 } 3270 } 3271 3272 3279 public Reader getNCharacterStream(int columnIndex) throws SQLException { 3280 try { 3281 debugCodeCall("getNCharacterStream", columnIndex); 3282 return get(columnIndex).getReader(); 3283 } catch(Throwable e) { 3284 throw logAndConvert(e); 3285 } 3286 } 3287 3288 3295 public Reader getNCharacterStream(String columnName) throws SQLException { 3296 try { 3297 debugCodeCall("getNCharacterStream", columnName); 3298 return get(columnName).getReader(); 3299 } catch(Throwable e) { 3300 throw logAndConvert(e); 3301 } 3302 } 3303 3304 3312 public void updateNCharacterStream(int columnIndex, Reader x, int length) throws SQLException { 3313 updateNCharacterStream(columnIndex, x, (long) length); 3314 } 3315 3316 3323 public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { 3324 updateNCharacterStream(columnIndex, x, -1); 3325 } 3326 3327 3335 public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { 3336 try { 3337 if(debug()) { 3338 debugCode("updateNCharacterStream("+columnIndex+", x, "+length+");"); 3339 } 3340 Value v = conn.createClob(x, length); 3341 update(columnIndex, v); 3342 } catch(Throwable e) { 3343 throw logAndConvert(e); 3344 } 3345 } 3346 3347 3355 public void updateNCharacterStream(String columnName, Reader x, int length) throws SQLException { 3356 updateNCharacterStream(columnName, x, (long) length); 3357 } 3358 3359 3366 public void updateNCharacterStream(String columnName, Reader x) throws SQLException { 3367 updateNCharacterStream(columnName, x, -1); 3368 } 3369 3370 3378 public void updateNCharacterStream(String columnName, Reader x, long length) throws SQLException { 3379 try { 3380 if(debug()) { 3381 debugCode("updateNCharacterStream("+quote(columnName)+", x, "+length+");"); 3382 } 3383 Value v = conn.createClob(x, length); 3384 update(columnName, v); 3385 } catch(Throwable e) { 3386 throw logAndConvert(e); 3387 } 3388 } 3389 3390 3394 3401 3403 3407 3414 3416} 3417 | Popular Tags |