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