1 2 package in.co.daffodil.db.jdbc; 3 4 import java.io.*; 5 import java.math.BigDecimal ; 6 import java.sql.*; 7 import java.sql.Date ; 8 import java.util.Calendar ; 9 10 import com.daffodilwoods.daffodildb.client.*; 11 import com.daffodilwoods.daffodildb.server.datadictionarysystem._ColumnCharacteristics; 12 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Datatype; 13 import com.daffodilwoods.database.resource.DException; 14 15 145 146 public class DaffodilDBResultSet implements ResultSet { 147 148 private _RecordSetBufferIterator bufferIterator; 149 private DaffodilDBStatement statement; 150 private Navigator navigator; 151 private RowModifier rowModifier; 152 DaffodilDBConnection connection; 153 154 int concurrency = CONCUR_READ_ONLY; 155 int type = TYPE_FORWARD_ONLY; 156 int fetchSize = 0; 157 int fetchDirection = FETCH_FORWARD; 158 DaffodilDBResultSetMetaData metaData; 159 SQLWarning sqlWarning; 160 private _Record currentRecord = null; 161 private int filedCount = 0; 162 private int[] fieldTypeArrary = null; 163 public DaffodilDBResultSet(DaffodilDBStatement statement) throws SQLException { 164 this.statement = statement; 165 connection = (DaffodilDBConnection) statement.getConnection(); 166 } 167 168 184 185 public boolean next() throws SQLException { 186 this.currentRecord = null; 187 checkResultSetStatus("next"); 188 return navigator.next(); 189 } 190 191 206 207 public void close() throws SQLException { 208 try { 209 if (statement != null) { 210 if (rowModifier != null) 211 bufferIterator.getRecordSetBuffer().removeDataOperationListener( 212 rowModifier); 213 statement.resultSet = null; 214 statement = null; 215 } 216 } catch (DException ex) { 217 throw ex.getSqlException(null); 218 } 219 } 220 221 233 234 public boolean wasNull() throws SQLException { 235 checkResultSetStatus("wasNull"); 236 if (navigator.lastRetrievedColumn == -1) { 237 DException dex = new DException("DSE725", null); 238 throw dex.getSqlException(connection.getLocale()); 239 } 240 return navigator.lastRetrievedColumnValue == null; 241 } 242 243 244 254 255 public String getString(int columnIndex) throws SQLException { 256 Object columnValue = getObjectFromCurrentRow(columnIndex, Types.VARCHAR); 257 return columnValue == null ? null : columnValue.toString(); 258 } 259 260 270 public boolean getBoolean(int columnIndex) throws SQLException { 271 Boolean columnValue = (Boolean ) getObjectFromCurrentRow(columnIndex, 272 16 273 274 ); 275 return columnValue == null ? false : columnValue.booleanValue(); 276 } 277 278 288 289 public byte getByte(int columnIndex) throws SQLException { 290 Integer columnValue = (Integer ) getObjectFromCurrentRow(columnIndex, Types.TINYINT); 291 return columnValue == null ? (byte) 0 : columnValue.byteValue(); 292 } 293 294 304 305 public short getShort(int columnIndex) throws SQLException { 306 Integer shortValue = (Integer ) getObjectFromCurrentRow(columnIndex, Types.SMALLINT); 307 return shortValue == null ? (short) 0 : shortValue.shortValue(); 308 } 309 310 320 321 public int getInt(int columnIndex) throws SQLException { 322 Integer intValue = (Integer ) getObjectFromCurrentRow(columnIndex, Types.INTEGER); 323 return intValue == null ? 0 : intValue.intValue(); 324 } 325 326 336 337 public long getLong(int columnIndex) throws SQLException { 338 Long longValue = (Long ) getObjectFromCurrentRow(columnIndex, Types.BIGINT); 339 return longValue == null ? 0l : longValue.longValue(); 340 } 341 342 352 353 public float getFloat(int columnIndex) throws SQLException { 354 Float floatValue = (Float ) getObjectFromCurrentRow(columnIndex, Types.REAL); 355 return floatValue == null ? 0f : floatValue.floatValue(); 356 } 357 358 368 369 public double getDouble(int columnIndex) throws SQLException { 370 Double doubleValue = (Double ) getObjectFromCurrentRow(columnIndex, Types.DOUBLE); 371 return doubleValue == null ? 0.0 : doubleValue.doubleValue(); 372 } 373 374 386 387 public BigDecimal getBigDecimal(int columnIndex, int scale) throws 388 SQLException { 389 BigDecimal columnValue = (BigDecimal ) getObjectFromCurrentRow(columnIndex, Types.DECIMAL); 390 if (columnValue == null || scale == -1) 391 return columnValue; 392 return columnValue.setScale(scale, columnValue.ROUND_DOWN); 393 } 394 395 406 407 public byte[] getBytes(int columnIndex) throws SQLException { 408 byte[] columnValue = (byte[]) getObjectFromCurrentRow(columnIndex, Types.BINARY); 409 return columnValue; 410 } 411 412 422 423 public java.sql.Date getDate(int columnIndex) throws SQLException { 424 return getDate(columnIndex, null); 425 } 426 427 437 438 public Time getTime(int columnIndex) throws SQLException { 439 return getTime(columnIndex, null); 440 } 441 442 452 453 public Timestamp getTimestamp(int columnIndex) throws SQLException { 454 return getTimestamp(columnIndex, null); 455 } 456 457 480 481 public InputStream getAsciiStream(int columnIndex) throws SQLException { 482 byte[] bytes = getBytes(columnIndex); 483 if (bytes == null) 484 return null; 485 byte[] unicodeBytes; 486 try { 487 unicodeBytes = Utilities.convertBytesToAsciiBytes(bytes); 488 } catch (sun.io.MalformedInputException be) { 489 be.printStackTrace(); 490 DException dex = new DException("DSE297", null); 491 throw dex.getSqlException(connection.getLocale()); 492 } 493 ByteArrayInputStream in = new ByteArrayInputStream(unicodeBytes); 494 return in; 495 } 496 497 526 527 public java.io.InputStream getUnicodeStream(int columnIndex) throws 528 SQLException { 529 byte[] bytes = getBytes(columnIndex); 530 if (bytes == null) 531 return null; 532 byte[] unicodeBytes; 533 try { 534 unicodeBytes = Utilities.convertBytesToUnicodeBytes(bytes); 535 } catch (sun.io.MalformedInputException ex) { 536 DException dex = new DException("DSE297", null); 537 throw dex.getSqlException(connection.getLocale()); 538 } 539 ByteArrayInputStream in = new ByteArrayInputStream(unicodeBytes); 540 return in; 541 } 542 543 564 565 public InputStream getBinaryStream(int columnIndex) throws SQLException { 566 byte[] bytes = getBytes(columnIndex); 567 return bytes == null ? null : new ByteArrayInputStream(bytes); 568 } 569 570 588 589 public Object getObject(int columnIndex, java.util.Map map) throws 590 SQLException { 591 Object columnValue = getObjectFromCurrentRow(columnIndex, Integer.MIN_VALUE); 592 if (columnValue == null) 593 return null; 594 try { 595 Object newvalue = Utilities.convertObject(columnValue,fieldTypeArrary[columnIndex -1 ] ); 596 597 609 610 return newvalue; 611 } catch (DException de) { 612 throw de.getSqlException(connection.getLocale()); 613 } 614 } 615 616 627 628 public Ref getRef(int columnIndex) throws SQLException { 629 checkResultSetStatus("getRef"); 630 DException dex = new DException("DSE22", new Object [] {"User-defined type"}); 631 throw dex.getSqlException(connection.getLocale()); 632 } 633 634 645 646 public Blob getBlob(int columnIndex) throws SQLException { 647 checkResultSetStatus("getBlob"); 648 Blob clob = (Blob) getObject(columnIndex); 649 navigator.lastRetrievedColumnValue = clob == null ? null : clob; 650 return clob; 651 } 652 653 664 665 public Clob getClob(int columnIndex) throws SQLException { 666 Clob clob = (Clob) getObjectFromCurrentRow(columnIndex, Types.CLOB); 667 return clob; 668 } 669 670 681 682 public Array getArray(int columnIndex) throws SQLException { 683 checkResultSetStatus("getArray"); 684 DException dex = new DException("DSE22", new Object [] {"User-defined type"}); 685 throw dex.getSqlException(connection.getLocale()); 686 } 687 688 705 706 public Object getObject(String colName, java.util.Map map) throws 707 SQLException { 708 return getObject(findColumn(colName), map); 709 } 710 711 722 723 public Ref getRef(String colName) throws SQLException { 724 checkResultSetStatus("getRef"); 725 return getRef(findColumn(colName)); 726 } 727 728 739 740 public Blob getBlob(String colName) throws SQLException { 741 checkResultSetStatus("getBlob"); 742 return getBlob(findColumn(colName)); 743 } 744 745 756 757 public Clob getClob(String colName) throws SQLException { 758 checkResultSetStatus("getClob"); 759 return getClob(findColumn(colName)); 760 } 761 762 773 774 public Array getArray(String colName) throws SQLException { 775 checkResultSetStatus("getArray"); 776 return getArray(findColumn(colName)); 777 } 778 779 796 797 public java.sql.Date getDate(int columnIndex, Calendar cal) throws 798 SQLException { 799 java.sql.Date columnValue = (java.sql.Date ) getObjectFromCurrentRow( 800 columnIndex, Types.DATE); 801 if (columnValue == null || cal == null) 802 return columnValue; 803 cal.setTime(columnValue); 804 return new com.daffodilwoods.daffodildb.utils.DBDate(cal.getTime().getTime() 805 806 ); 807 } 808 809 826 827 public java.sql.Date getDate(String columnName, Calendar cal) throws 828 SQLException { 829 return getDate(findColumn(columnName), cal); 830 } 831 832 850 851 public Time getTime(int columnIndex, Calendar cal) throws SQLException { 852 Time timeObj = (Time) getObjectFromCurrentRow(columnIndex, Types.TIME); 853 if (timeObj == null) 854 return null; 855 Date timeObject = new com.daffodilwoods.daffodildb.utils.DBDate(timeObj.getTime()); 856 if (cal == null) { 857 Time time = new Time(timeObject.getTime()); 858 navigator.lastRetrievedColumnValue = time; 859 return time; 860 } 861 cal.setTime(timeObject); 862 Time calTime = new Time(timeObject.getTime() 863 ); 865 navigator.lastRetrievedColumnValue = calTime; 866 return calTime; 867 } 868 869 886 887 public Time getTime(String columnName, Calendar cal) throws SQLException { 888 return getTime(findColumn(columnName), cal); 889 } 890 891 909 910 public java.sql.Timestamp getTimestamp(int columnIndex, Calendar cal) throws 911 SQLException { 912 Timestamp timestamp = (Timestamp) getObjectFromCurrentRow(columnIndex, 913 Types.TIMESTAMP); 914 if (timestamp == null || cal == null) { 915 return timestamp; 916 } 917 Date timeObject = new com.daffodilwoods.daffodildb.utils.DBDate(timestamp.getTime()); 918 Calendar cal1 = setCalendarAttributes(cal, timeObject); 919 Timestamp calTime = new Timestamp(cal1.getTime().getTime()); 920 navigator.lastRetrievedColumnValue = calTime; 921 return calTime; 922 } 923 924 941 942 public java.sql.Timestamp getTimestamp(String columnName, Calendar cal) throws 943 SQLException { 944 return getTimestamp(findColumn(columnName), cal); 945 } 946 947 948 958 959 public String getString(String columnName) throws SQLException { 960 return getString(findColumn(columnName)); 961 } 962 963 973 974 public boolean getBoolean(String columnName) throws SQLException { 975 return getBoolean(findColumn(columnName)); 976 } 977 978 988 989 public byte getByte(String columnName) throws SQLException { 990 return getByte(findColumn(columnName)); 991 } 992 993 1003 1004 public short getShort(String columnName) throws SQLException { 1005 return getShort(findColumn(columnName)); 1006 } 1007 1008 1018 1019 public int getInt(String columnName) throws SQLException { 1020 return getInt(findColumn(columnName)); 1021 } 1022 1023 1033 1034 public long getLong(String columnName) throws SQLException { 1035 return getLong(findColumn(columnName)); 1036 } 1037 1038 1048 1049 public float getFloat(String columnName) throws SQLException { 1050 return getFloat(findColumn(columnName)); 1051 } 1052 1053 1063 1064 public double getDouble(String columnName) throws SQLException { 1065 return getDouble(findColumn(columnName)); 1066 } 1067 1068 1080 1081 public BigDecimal getBigDecimal(String columnName, int scale) throws 1082 SQLException { 1083 return getBigDecimal(findColumn(columnName), scale); 1084 } 1085 1086 1097 1098 public byte[] getBytes(String columnName) throws SQLException { 1099 return getBytes(findColumn(columnName)); 1100 } 1101 1102 1112 1113 public java.sql.Date getDate(String columnName) throws SQLException { 1114 return getDate(findColumn(columnName), null); 1115 } 1116 1117 1128 1129 public Time getTime(String columnName) throws SQLException { 1130 return getTime(findColumn(columnName), null); 1131 } 1132 1133 1143 1144 public java.sql.Timestamp getTimestamp(String columnName) throws SQLException { 1145 return getTimestamp(findColumn(columnName), null); 1146 } 1147 1148 1170 1171 public java.io.InputStream getAsciiStream(String columnName) throws 1172 SQLException { 1173 return getAsciiStream(findColumn(columnName)); 1174 } 1175 1176 1203 1204 public java.io.InputStream getUnicodeStream(String columnName) throws 1205 SQLException { 1206 return getUnicodeStream(findColumn(columnName)); 1207 } 1208 1209 1230 1231 public InputStream getBinaryStream(String columnName) throws SQLException { 1232 return getBinaryStream(findColumn(columnName)); 1233 } 1234 1235 1236 1259 1260 public SQLWarning getWarnings() throws SQLException { 1261 checkResultSetStatus("getWarnings"); 1262 return sqlWarning; 1263 } 1264 1265 1273 public void clearWarnings() throws SQLException { 1274 checkResultSetStatus("clearWarnings"); 1275 sqlWarning = null; 1276 } 1277 1278 1301 1302 public String getCursorName() throws SQLException { 1303 checkResultSetStatus("getCursorName"); 1304 DException dex = new DException("DSE16", new Object [] {"getCursorName"}); 1305 throw dex.getSqlException(connection.getLocale()); 1306 } 1307 1308 1317 public ResultSetMetaData getMetaData() throws SQLException { 1318 checkResultSetStatus("getMetaData"); 1319 return metaData; 1320 } 1321 1322 1348 1349 public Object getObject(int columnIndex) throws SQLException { 1350 try { 1351 return getObjectFromCurrentRow(columnIndex,Integer.MIN_VALUE); 1352 } catch (Exception ex) { 1353 return null; 1354 } 1355 } 1356 1357 1383 1384 public Object getObject(String columnName) throws SQLException { 1385 return getObject(findColumn(columnName), null); 1386 } 1387 1388 1389 1398 1399 public int findColumn(String columnName) throws SQLException { 1400 checkResultSetStatus("findColumn"); 1401 return this.metaData.getColumnIndex(columnName); 1402 } 1403 1404 1405 1416 1417 public Reader getCharacterStream(int columnIndex) throws SQLException { 1418 byte[] columnBytes = getBytes(columnIndex); 1419 return columnBytes == null ? null : 1420 new InputStreamReader(new ByteArrayInputStream(columnBytes)); 1421 } 1422 1423 1435 1436 public Reader getCharacterStream(String columnName) throws SQLException { 1437 return getCharacterStream(findColumn(columnName)); 1438 } 1439 1440 1452 1453 public BigDecimal getBigDecimal(int columnIndex) throws SQLException { 1454 return getBigDecimal(columnIndex, -1); 1455 } 1456 1457 1470 public BigDecimal getBigDecimal(String columnName) throws SQLException { 1471 return getBigDecimal(findColumn(columnName), -1); 1472 } 1473 1474 1475 1485 1486 public boolean isBeforeFirst() throws SQLException { 1487 checkResultSetStatus("isBeforeFirst"); 1488 return navigator.isBeforeFirst(); 1489 } 1490 1491 1501 1502 public boolean isAfterLast() throws SQLException { 1503 checkResultSetStatus("isAfterLast"); 1504 return navigator.isAfterLast(); 1505 } 1506 1507 1516 1517 public boolean isFirst() throws SQLException { 1518 checkResultSetStatus("isFirst"); 1519 return navigator.isFirst(); 1520 } 1521 1522 1535 1536 public boolean isLast() throws SQLException { 1537 checkResultSetStatus("isLast"); 1538 return navigator.isLast(); 1539 } 1540 1541 1550 1551 public void beforeFirst() throws SQLException { 1552 this.currentRecord = null; 1553 checkResultSetStatus("beforeFirst"); 1554 navigator.beforeFirst(); 1555 } 1556 1557 1565 1566 public void afterLast() throws SQLException { 1567 this.currentRecord = null; 1568 checkResultSetStatus("afterLast"); 1569 navigator.afterLast(); 1570 } 1571 1572 1582 1583 public boolean first() throws SQLException { 1584 this.currentRecord = null; 1585 checkResultSetStatus("first"); 1586 return navigator.first(); 1587 } 1588 1589 1599 1600 public boolean last() throws SQLException { 1601 this.currentRecord = null; 1602 checkResultSetStatus("last"); 1603 return navigator.last(); 1604 } 1605 1606 1614 1615 public int getRow() throws SQLException { 1616 checkResultSetStatus("getRow"); 1617 return navigator.getRow(); 1618 } 1619 1620 1656 1657 public boolean absolute(int row) throws SQLException { 1658 this.currentRecord = null; 1659 checkResultSetStatus("absolute"); 1660 return navigator.absolute(row); 1661 } 1662 1663 1685 1686 public boolean relative(int rows) throws SQLException { 1687 this.currentRecord = null; 1688 checkResultSetStatus("relative"); 1689 return navigator.relative(rows); 1690 } 1691 1692 1702 1703 public boolean previous() throws SQLException { 1704 this.currentRecord = null; 1705 checkResultSetStatus("previous"); 1706 return navigator.previous(); 1707 } 1708 1709 1710 1751 1752 public void setFetchDirection(int direction) throws SQLException { 1753 1755 checkResultSetStatus("setFetchDirection"); 1756 if (direction != FETCH_FORWARD && direction != FETCH_REVERSE && 1757 direction != FETCH_UNKNOWN) { 1758 DException dex = new DException("DSE738", 1759 new Object [] {new Integer (direction)}); 1760 throw dex.getSqlException(connection.getLocale()); 1761 } 1762 if (type == TYPE_FORWARD_ONLY && direction != FETCH_FORWARD) { 1763 DException dex = new DException("DSE415", null); 1764 throw dex.getSqlException(connection.getLocale()); 1765 } 1766 fetchDirection = direction; 1767 bufferIterator.getRecordSetBuffer().setFetchDirection(direction); 1768 } 1769 1770 1779 1780 public int getFetchDirection() throws SQLException { 1781 checkResultSetStatus("getFetchDirection"); 1782 return fetchDirection; 1783 } 1784 1785 1801 1802 public void setFetchSize(int rows) throws SQLException { 1803 1804 checkResultSetStatus("setFetchSize"); 1805 if (rows < 0 || (statement.getMaxRows() != 0 && rows > statement.getMaxRows())) { 1806 DException dex = new DException("DSE518", null); 1807 throw dex.getSqlException(connection.getLocale()); 1808 } 1809 fetchSize = rows; 1810 } 1811 1812 1821 1822 public int getFetchSize() throws SQLException { 1823 checkResultSetStatus("getFetchSize"); 1824 return fetchSize; 1825 } 1826 1827 1856 1857 public int getType() throws SQLException { 1858 checkResultSetStatus("getType"); 1859 return type; 1860 } 1861 1862 1885 1886 public int getConcurrency() throws SQLException { 1887 checkResultSetStatus("getConcurrency"); 1888 return concurrency; 1889 } 1890 1891 1892 1902 1903 public boolean rowUpdated() throws SQLException { 1904 checkResultSetStatus("rowUpdated"); 1905 checkUpdatable(); 1906 return rowModifier.rowUpdated(); 1907 } 1908 1909 1921 1922 public boolean rowInserted() throws SQLException { 1923 checkResultSetStatus("rowInserted"); 1924 checkUpdatable(); 1925 return rowModifier.rowInserted(); 1926 } 1927 1928 1941 1942 public boolean rowDeleted() throws SQLException { 1943 checkResultSetStatus("rowDeleted"); 1944 checkUpdatable(); 1945 return rowModifier.rowDeleted(); 1946 } 1947 1948 1960 1961 public void updateNull(int columnIndex) throws SQLException { 1962 checkingBeforeUpdate(columnIndex); 1963 checkAllowedNull(columnIndex); 1964 rowModifier.updateObject(columnIndex, null); 1965 } 1966 1967 1979 1980 public void updateBoolean(int columnIndex, boolean x) throws SQLException { 1981 checkingBeforeUpdate(columnIndex); 1982 rowModifier.updateObject(columnIndex, Utilities.getBooleanValue(x)); 1983 } 1984 1985 1997 1998 public void updateByte(int columnIndex, byte x) throws SQLException { 1999 checkingBeforeUpdate(columnIndex); 2000 rowModifier.updateObject(columnIndex, new Byte (x)); 2001 } 2002 2003 2015 public void updateShort(int columnIndex, short x) throws SQLException { 2016 checkingBeforeUpdate(columnIndex); 2017 rowModifier.updateObject(columnIndex, new Short (x)); 2018 } 2019 2020 2032 public void updateInt(int columnIndex, int x) throws SQLException { 2033 checkingBeforeUpdate(columnIndex); 2034 rowModifier.updateObject(columnIndex, new Integer (x)); 2035 } 2036 2037 2049 2050 public void updateLong(int columnIndex, long x) throws SQLException { 2051 checkingBeforeUpdate(columnIndex); 2052 rowModifier.updateObject(columnIndex, new Long (x)); 2053 } 2054 2055 2067 public void updateFloat(int columnIndex, float x) throws SQLException { 2068 checkingBeforeUpdate(columnIndex); 2069 rowModifier.updateObject(columnIndex, new Float (x)); 2070 } 2071 2072 2084 public void updateDouble(int columnIndex, double x) throws SQLException { 2085 checkingBeforeUpdate(columnIndex); 2086 rowModifier.updateObject(columnIndex, new Double (x)); 2087 } 2088 2089 2102 2103 public void updateBigDecimal(int columnIndex, BigDecimal x) throws 2104 SQLException { 2105 checkingBeforeUpdate(columnIndex); 2106 rowModifier.updateObject(columnIndex, x); 2107 } 2108 2109 2121 public void updateString(int columnIndex, String x) throws SQLException { 2122 checkingBeforeUpdate(columnIndex); 2123 rowModifier.updateObject(columnIndex, x); 2124 } 2125 2126 2138 2139 public void updateBytes(int columnIndex, byte x[]) throws SQLException { 2140 checkingBeforeUpdate(columnIndex); 2141 try { 2142 Object columnValue = Utilities.convertObject(x, 2143 fieldTypeArrary[columnIndex-1]); 2144 rowModifier.updateObject(columnIndex, columnValue); 2145 } catch (DException de) { 2146 throw de.getSqlException(connection.getLocale()); 2147 } 2148 } 2149 2150 2162 2163 public void updateDate(int columnIndex, java.sql.Date x) throws SQLException { 2164 checkingBeforeUpdate(columnIndex); 2165 rowModifier.updateObject(columnIndex, x); 2166 } 2167 2168 2180 2181 public void updateTime(int columnIndex, java.sql.Time x) throws SQLException { 2182 checkingBeforeUpdate(columnIndex); 2183 rowModifier.updateObject(columnIndex, x); 2184 } 2185 2186 2199 2200 public void updateTimestamp(int columnIndex, java.sql.Timestamp x) throws 2201 SQLException { 2202 checkingBeforeUpdate(columnIndex); 2203 rowModifier.updateObject(columnIndex, x); 2204 } 2205 2206 2219 public void updateAsciiStream(int columnIndex, InputStream x, int length) throws 2220 SQLException { 2221 checkingBeforeUpdate(columnIndex); 2222 byte[] bytes = new byte[length]; 2223 try { 2224 x.read(bytes); 2225 } catch (IOException ex) { 2226 DException dex = new DException("DSE146", null); 2227 throw dex.getSqlException(connection.getLocale()); 2228 } 2229 rowModifier.updateObject(columnIndex, bytes); 2230 } 2231 2232 2245 2246 public void updateBinaryStream(int columnIndex, java.io.InputStream x, 2247 int length) throws SQLException { 2248 checkingBeforeUpdate(columnIndex); 2249 byte[] bytes = new byte[length]; 2250 try { 2251 x.read(bytes); 2252 } catch (IOException ex) { 2253 DException dex = new DException("DSE146", null); 2254 throw dex.getSqlException(connection.getLocale()); 2255 } 2256 rowModifier.updateObject(columnIndex, bytes); 2257 } 2258 2259 2272 2273 public void updateCharacterStream(int columnIndex, java.io.Reader x, 2274 int length) throws SQLException { 2275 checkingBeforeUpdate(columnIndex); 2276 char[] chars = new char[length]; 2277 byte[] bytes = null; 2278 try { 2279 x.read(chars); 2280 bytes = Utilities.convertCharsToBytes(chars); 2281 } catch (java.io.IOException ie) { 2282 DException dex = new DException("DSE297", null); 2283 throw dex.getSqlException(connection.getLocale()); 2284 } 2285 rowModifier.updateObject(columnIndex, bytes); 2286 } 2287 2288 2304 2305 public void updateObject(int columnIndex, Object x, int scale) throws 2306 SQLException { 2307 checkingBeforeUpdate(columnIndex); 2308 int type =fieldTypeArrary[columnIndex -1]; 2309 if ( (type == Types.NUMERIC || type == Datatype.DECIMAL) && scale != -1) { 2310 try { 2311 x = Utilities.convertObject(x, Types.DECIMAL); 2312 } catch (DException de) { 2313 throw de.getSqlException(connection.getLocale()); 2314 } 2315 x = ( (java.math.BigDecimal ) x).setScale(scale, BigDecimal.ROUND_DOWN); 2316 } 2317 rowModifier.updateObject(columnIndex, x); 2318 } 2319 2320 2332 public void updateObject(int columnIndex, Object x) throws SQLException { 2333 updateObject(columnIndex, x, -1); 2334 } 2335 2336 2347 2348 public void updateNull(String columnName) throws SQLException { 2349 updateNull(findColumn(columnName)); 2350 } 2351 2352 2364 2365 public void updateBoolean(String columnName, boolean x) throws SQLException { 2366 updateBoolean(findColumn(columnName), x); 2367 } 2368 2369 2381 2382 public void updateByte(String columnName, byte x) throws SQLException { 2383 updateByte(findColumn(columnName), x); 2384 } 2385 2386 2398 2399 public void updateShort(String columnName, short x) throws SQLException { 2400 updateShort(findColumn(columnName), x); 2401 } 2402 2403 2415 2416 public void updateInt(String columnName, int x) throws SQLException { 2417 updateInt(findColumn(columnName), x); 2418 } 2419 2420 2432 2433 public void updateLong(String columnName, long x) throws SQLException { 2434 updateLong(findColumn(columnName), x); 2435 } 2436 2437 2449 2450 public void updateFloat(String columnName, float x) throws SQLException { 2451 updateFloat(findColumn(columnName), x); 2452 } 2453 2454 2466 2467 public void updateDouble(String columnName, double x) throws SQLException { 2468 updateDouble(findColumn(columnName), x); 2469 } 2470 2471 2484 2485 public void updateBigDecimal(String columnName, BigDecimal x) throws 2486 SQLException { 2487 updateBigDecimal(findColumn(columnName), x); 2488 } 2489 2490 2502 2503 public void updateString(String columnName, String x) throws SQLException { 2504 updateString(findColumn(columnName), x); 2505 } 2506 2507 2520 2521 public void updateBytes(String columnName, byte x[]) throws SQLException { 2522 updateBytes(findColumn(columnName), x); 2523 } 2524 2525 2537 2538 public void updateDate(String columnName, java.sql.Date x) throws 2539 SQLException { 2540 updateDate(findColumn(columnName), x); 2541 } 2542 2543 2555 2556 public void updateTime(String columnName, java.sql.Time x) throws 2557 SQLException { 2558 updateTime(findColumn(columnName), x); 2559 } 2560 2561 2574 2575 public void updateTimestamp(String columnName, java.sql.Timestamp x) throws 2576 SQLException { 2577 updateTimestamp(findColumn(columnName), x); 2578 } 2579 2580 2593 2594 public void updateAsciiStream(String columnName, InputStream x, int length) throws 2595 SQLException { 2596 updateAsciiStream(findColumn(columnName), x, length); 2597 } 2598 2599 2612 2613 public void updateBinaryStream(String columnName, java.io.InputStream x, 2614 int length) throws SQLException { 2615 updateBinaryStream(findColumn(columnName), x, length); 2616 } 2617 2618 2632 2633 public void updateCharacterStream(String columnName, java.io.Reader reader, 2634 int length) throws SQLException { 2635 updateCharacterStream(findColumn(columnName), reader, length); 2636 } 2637 2638 2654 2655 public void updateObject(String columnName, Object x, int scale) throws 2656 SQLException { 2657 updateObject(findColumn(columnName), x, scale); 2658 } 2659 2660 2672 2673 public void updateObject(String columnName, Object x) throws SQLException { 2674 updateObject(findColumn(columnName), x); 2675 } 2676 2677 2688 2689 public void insertRow() throws SQLException { 2690 checkResultSetStatus("insertRow"); 2691 checkUpdatable(); 2692 rowModifier.insertInitiate(); 2693 } 2694 2695 2704 public void updateRow() throws SQLException { 2705 checkResultSetStatus("updateRow"); 2706 checkUpdatable(); 2707 rowModifier.updateInitiate(); 2708 } 2709 2710 2719 2720 public void deleteRow() throws SQLException { 2721 checkResultSetStatus("deleteRow"); 2722 checkUpdatable(); 2723 checkValidRow(); 2724 rowModifier.deleteInitiate(); 2725 } 2726 2727 2755 2756 public void refreshRow() throws SQLException { 2757 checkResultSetStatus("refreshRow"); 2758 throw new UnsupportedOperationException (); 2759 } 2760 2761 2776 public void cancelRowUpdates() throws SQLException { 2777 checkResultSetStatus("cancelRowUpdates"); 2778 checkUpdatable(); 2779 rowModifier.cancelRowUpdates(); 2780 } 2781 2782 2806 public void moveToInsertRow() throws SQLException { 2807 checkResultSetStatus("moveToInsertRow"); 2808 checkUpdatable(); 2809 navigator.storeCurrentPosition(); 2810 } 2811 2812 2821 2822 public void moveToCurrentRow() throws SQLException { 2823 checkResultSetStatus("moveToCurrentRow"); 2824 navigator.moveToCurrentRow(); 2825 } 2826 2827 2840 2841 public Statement getStatement() throws SQLException { 2842 checkResultSetStatus("getStatement"); 2843 return statement; 2844 } 2845 2846 2847 2874 2875 public java.net.URL getURL(int columnIndex) throws SQLException { 2876 Object urlString = getObjectFromCurrentRow(columnIndex, Types.CHAR); 2877 if (urlString == null) 2878 return null; 2879 try { 2880 java.net.URL url = new java.net.URL (urlString.toString()); 2881 return url; 2882 } catch (java.net.MalformedURLException N) { 2883 DException dex = new DException("DSE525", null); 2884 throw dex.getSqlException( ( (DaffodilDBConnection) statement. 2885 getConnection()).getLocale()); 2886 } 2887 } 2888 2889 2902 2903 public java.net.URL getURL(String columnName) throws SQLException { 2904 return getURL(findColumn(columnName)); 2905 } 2906 2907 2919 2920 public void updateRef(int columnIndex, java.sql.Ref x) throws SQLException { 2921 checkingBeforeUpdate(columnIndex); 2922 DException dex = new DException("DSE22", new Object [] {"User-defined type"}); 2923 throw dex.getSqlException(connection.getLocale()); 2924 } 2925 2926 2938 2939 public void updateRef(String columnName, java.sql.Ref x) throws SQLException { 2940 updateRef(findColumn(columnName), x); 2941 } 2942 2943 2955 2956 public void updateBlob(int columnIndex, Blob x) throws SQLException { 2957 checkingBeforeUpdate(columnIndex); 2958 rowModifier.updateObject(columnIndex, x); 2959 } 2960 2961 2973 2974 public void updateBlob(String columnName, Blob x) throws SQLException { 2975 updateBlob(findColumn(columnName), x); 2976 } 2977 2978 2990 2991 public void updateClob(int columnIndex, java.sql.Clob x) throws SQLException { 2992 checkingBeforeUpdate(columnIndex); 2993 rowModifier.updateObject(columnIndex, x); 2994 } 2995 2996 3008 3009 public void updateClob(String columnName, java.sql.Clob x) throws 3010 SQLException { 3011 updateClob(findColumn(columnName), x); 3012 } 3013 3014 3026 3027 public void updateArray(int columnIndex, java.sql.Array x) throws 3028 SQLException { 3029 checkingBeforeUpdate(columnIndex); 3030 DException dex = new DException("DSE22", new Object [] {"User-defined type"}); 3031 throw dex.getSqlException(connection.getLocale()); 3032 } 3033 3034 3046 3047 public void updateArray(String columnName, java.sql.Array x) throws 3048 SQLException { 3049 updateArray(findColumn(columnName), x); 3050 } 3051 3052 3056 3057 void setRecordSetBuffer(_RecordSetBuffer recordSetBuffer) throws SQLException { 3058 bufferIterator = recordSetBuffer.getIterator(); 3059 _ColumnCharacteristics clmchs = bufferIterator.getRecordSetBuffer(). 3060 getColumnCharacteristics(); 3061 metaData = new DaffodilDBResultSetMetaData(statement.connection); 3062 metaData.setColumnCharacteristics(clmchs); 3063 filedCount = metaData.getColumnCount(); 3064 fieldTypeArrary = new int[filedCount]; 3065 for (int i = 0; i < filedCount; i++) { 3066 fieldTypeArrary[i] = metaData.getColumnType(i + 1); 3067 } 3068 3069 } 3070 3071 _RecordSetBufferIterator getRecordSetBufferIterator() { 3072 return bufferIterator; 3073 } 3074 3075 public void setConcurreny(int concurrency) throws SQLException { 3076 try { 3077 if (concurrency != CONCUR_READ_ONLY && concurrency != CONCUR_UPDATABLE) { 3078 DException dex = new DException("DSE511", 3079 new Object [] {new Integer (concurrency)}); 3080 throw dex.getSqlException(connection.getLocale()); 3081 } 3082 this.concurrency = concurrency; 3083 if (concurrency == CONCUR_UPDATABLE) { 3084 rowModifier = new RowModifier(); 3085 bufferIterator.getRecordSetBuffer().addDataOperationListener( 3086 rowModifier); 3087 } 3088 } catch (DException ex) { 3089 throw ex.getSqlException(null); 3090 } 3091 } 3092 3093 public int getRowCount() throws SQLException { 3094 int count = bufferIterator.getRowCount(); 3095 return count; 3096 } 3097 3098 public void setType(int type) throws SQLException { 3099 if (! (type == TYPE_FORWARD_ONLY || type == TYPE_SCROLL_INSENSITIVE || 3100 type == TYPE_SCROLL_SENSITIVE)) { 3101 DException dex = new DException("DSE1024", null); 3102 throw dex.getSqlException(connection.getLocale()); 3103 } 3104 this.type = type; 3105 navigator = new Navigator(); 3106 } 3107 3108 private void checkUpdatable() throws SQLException { 3109 if (concurrency != CONCUR_UPDATABLE) { 3110 DException dex = new DException("DSE870", null); 3111 throw dex.getSqlException(connection.getLocale()); 3112 } 3113 } 3114 3115 3116 3117 private void checkAllowedNull(int columnIndex) throws SQLException { 3118 int status = metaData.isNullable(columnIndex); 3119 if (status == ResultSetMetaData.columnNoNulls) { 3120 DException dex = new DException("DSE750", null); 3121 throw dex.getSqlException(connection.getLocale()); 3122 } 3123 } 3124 3125 void addWarning(String reason) { 3126 SQLWarning warning = new SQLWarning(reason); 3127 if (sqlWarning == null) 3128 sqlWarning = warning; 3129 sqlWarning.setNextWarning(warning); 3130 } 3131 3132 private void checkResultSetStatus(String methodName) throws SQLException { 3133 if (statement == null) 3134 throw new DException("DSE5027", 3135 null).getSqlException(connection.getLocale()); 3136 if (connection.isClosed()) 3137 throw new DException("DSE279", null).getSqlException(connection.getLocale()); 3138 } 3139 3140 private Object getObjectFromCurrentRow(int columnIndex, int columnType) throws 3141 SQLException { 3142 checkResultSetStatus(""); 3143 checkValidRow(); 3144 checkValidColumn(columnIndex); 3145 navigator.lastRetrievedColumn = columnIndex; 3146 Object columnValue = getObject(columnIndex, columnType); 3147 navigator.lastRetrievedColumnValue = columnValue; 3148 return columnValue; 3149 } 3150 3151 private Object getObject(int columnIndex, int requiredType) throws 3152 SQLException { 3153 Object columnValue = navigator.getObject(columnIndex); 3154 if (columnValue == null) 3155 return columnValue; 3156 try { 3157 int conversionType = requiredType == Integer.MIN_VALUE ? fieldTypeArrary[columnIndex - 1] : requiredType; 3158 return requiredType == Integer.MIN_VALUE && 3159 isConversionNotRequired(fieldTypeArrary[columnIndex - 1]) ? 3160 columnValue : 3161 Utilities.convertObject(columnValue,conversionType); 3162 } catch (DException d) { 3163 throw d.getSqlException(connection.getLocale()); 3164 } 3165 } 3166 3167 private boolean isConversionNotRequired(int type ){ 3168 return (type == Types.TINYINT || type == Types.SMALLINT || 3169 type == Types.BINARY || type == Types.LONGVARBINARY || 3170 type == Types.VARBINARY || type == Types.BIT || type == Types.LONGVARCHAR) ? false : true; 3171 } 3172 private void checkingBeforeUpdate(int columnIndex) throws SQLException { 3173 checkResultSetStatus("updateNull"); 3174 checkValidRow(); 3175 checkUpdatable(); 3176 checkValidColumn(columnIndex); 3177 } 3178 3179 private void checkValidColumn(int columnIndex) throws SQLException { 3180 if (columnIndex < 1 || columnIndex > filedCount) { 3181 DException dex = new DException("DSE255", 3182 new Object [] {metaData. 3183 getColumnName(columnIndex), 3184 metaData.getTableName(columnIndex)}); 3185 throw dex.getSqlException(connection.getLocale()); 3186 } 3187 } 3188 3189 private void checkValidRow() throws SQLException { 3190 if (navigator.isBeforeFirst() || navigator.isAfterLast()) { 3191 DException dex = new DException("DSE294", null); 3192 throw dex.getSqlException(connection.getLocale()); 3193 } 3194 } 3195 3196 class Navigator { 3197 boolean beforeFirst = true; 3198 boolean afterLast = false; 3199 int currentRow = 0; 3200 int rowCount; 3201 int lastCurrentRow = 0; int lastRetrievedColumn = -1; 3203 Object lastRetrievedColumnValue = null; 3204 3205 3206 Navigator() throws SQLException { 3207 if (type != ResultSet.TYPE_FORWARD_ONLY) 3208 rowCount = bufferIterator.getRowCount(); 3209 } 3210 3211 private void checkScrollable() throws SQLException { 3212 if ( type == TYPE_FORWARD_ONLY) { 3213 DException dex = new DException("DSE871", null); 3214 throw dex.getSqlException(connection.getLocale()); 3215 } 3216 } 3217 3218 Object getObject(int columnIndex) throws SQLException { 3219 columnIndex = columnIndex - DaffodilDBDriver.COLUMN_OFFSET; 3220 if (concurrency == CONCUR_UPDATABLE && 3221 currentRow == 0) 3222 return rowModifier.getObject(columnIndex); 3223 if(currentRecord == null) 3224 currentRecord = (_Record) bufferIterator.getCurrent(); 3225 3226 return lastRetrievedColumnValue = (currentRecord == null ? null : 3227 currentRecord.getColumnValue( 3228 columnIndex)); 3229 } 3230 3231 boolean absolute(int row) throws SQLException { 3232 checkScrollable(); 3233 clearUpdateBuffer(); 3234 row = row < 0 ? rowCount + row + 1 : row; 3235 if (row <= 0) { 3236 beforeFirst(); 3237 return false; 3238 } 3239 if (row > rowCount) { 3240 afterLast(); 3241 return false; 3242 } 3243 moveToRow(row); 3244 lastRetrievedColumn = -1; 3245 return true; 3246 } 3247 3248 void afterLast() throws SQLException { 3249 checkScrollable(); 3250 clearUpdateBuffer(); 3251 beforeFirst = false; 3252 afterLast = true; 3253 currentRow = rowCount + 1; 3254 lastRetrievedColumn = -1; 3255 bufferIterator.bottom(); 3256 } 3257 3258 void beforeFirst() throws SQLException { 3259 checkScrollable(); 3260 clearUpdateBuffer(); 3261 beforeFirst = true; 3262 afterLast = false; 3263 currentRow = 0; lastRetrievedColumn = -1; 3265 bufferIterator.top(); 3266 } 3267 3268 boolean first() throws SQLException { 3269 checkScrollable(); 3270 clearUpdateBuffer(); 3271 if (bufferIterator.top()) { 3272 currentRow = 1; 3273 lastRetrievedColumn = -1; 3274 beforeFirst = false; 3275 afterLast = false; 3276 return true; 3277 } 3278 return false; 3279 } 3280 3281 int getRow() throws SQLException { 3282 if (beforeFirst || afterLast) 3283 return 0; 3284 return currentRow; 3285 } 3286 3287 boolean isAfterLast() throws SQLException { 3288 return afterLast; 3289 } 3290 3291 boolean isBeforeFirst() throws SQLException { 3292 return beforeFirst; 3293 } 3294 3295 boolean isFirst() throws SQLException { 3296 return currentRow == 1; 3297 } 3298 3299 boolean isLast() throws SQLException { 3300 return bufferIterator.isBottom() && isAfterLast() == false; 3301 } 3302 3303 boolean last() throws SQLException { 3304 checkScrollable(); 3305 clearUpdateBuffer(); 3306 if (bufferIterator.bottom()) { 3307 currentRow = rowCount; 3308 lastRetrievedColumn = -1; 3309 beforeFirst = false; 3310 afterLast = false; 3311 return true; 3312 } 3313 return false; 3314 } 3315 3316 void moveToCurrentRow() throws SQLException { 3317 clearUpdateBuffer(); 3318 lastRetrievedColumn = -1; 3319 if (lastCurrentRow != 0) { 3320 if (currentRow != lastCurrentRow) { 3321 first(); 3322 moveToRow(lastCurrentRow); 3323 } 3324 lastCurrentRow = 0; 3325 beforeFirst = false; 3326 afterLast = false; 3327 } 3328 } 3329 3330 3337 boolean next() throws SQLException { 3338 clearUpdateBuffer(); 3339 lastRetrievedColumn = -1; 3340 if (afterLast) 3341 return false; 3342 if (beforeFirst) { 3343 beforeFirst = false; 3344 if (bufferIterator.top()) { 3345 currentRow = 1; 3346 clearWarnings(); 3347 return true; 3348 } 3349 return false; 3350 } 3351 boolean next = bufferIterator.next(); 3352 currentRow++; 3353 if (next) { 3354 clearWarnings(); 3355 return true; 3356 } 3357 afterLast = true; 3358 return false; 3359 } 3360 3361 3368 boolean previous() throws SQLException { 3369 checkScrollable(); 3370 clearUpdateBuffer(); 3371 lastRetrievedColumn = -1; 3372 if (beforeFirst) 3373 return false; 3374 if (afterLast) { 3375 afterLast = false; 3376 currentRow--; 3377 if (bufferIterator.bottom()) { 3378 currentRow = rowCount; 3379 clearWarnings(); 3380 return true; 3381 } 3382 return false; 3383 } 3384 boolean previous = bufferIterator.previous(); 3385 currentRow--; 3386 if (previous) { 3387 clearWarnings(); 3388 return true; 3389 } 3390 currentRow = 0; 3391 beforeFirst = true; 3392 return false; 3393 } 3394 3395 boolean relative(int rows) throws SQLException { 3396 checkScrollable(); 3397 clearUpdateBuffer(); 3398 if (rows == 0) 3399 return currentRow > 0 && currentRow <= rowCount; 3400 lastRetrievedColumn = -1; 3401 int newRowIndex = currentRow + rows; 3402 if (newRowIndex <= 0) { 3403 beforeFirst(); 3404 return false; 3405 } 3406 if (newRowIndex > rowCount) { 3407 afterLast(); 3408 return false; 3409 } 3410 moveToRow(newRowIndex); 3411 return true; 3412 } 3413 3414 private void moveToRow(int rowIndex) throws SQLException { 3415 clearUpdateBuffer(); 3416 lastRetrievedColumn = -1; 3417 if (currentRow < rowIndex) { 3418 while (currentRow != rowIndex) { 3419 if (currentRow > 0) { 3420 if (!bufferIterator.next()) { 3421 break; 3422 } 3423 } 3424 currentRow++; 3425 } 3426 if (currentRow == rowCount + 1) { 3427 beforeFirst = false; 3428 afterLast = true; 3429 } else { 3430 beforeFirst = false; 3431 afterLast = false; 3432 } 3433 } else if (currentRow > rowIndex) { 3434 while (currentRow != rowIndex) { 3435 if (currentRow <= rowCount) { 3436 if (!bufferIterator.previous()) 3437 break; 3438 } 3439 currentRow--; 3440 } 3441 if (currentRow == 0) { 3442 beforeFirst = true; 3443 afterLast = false; 3444 } else { 3445 beforeFirst = false; 3446 afterLast = false; 3447 } 3448 } 3449 } 3450 3451 public void storeCurrentPosition() throws SQLException { 3452 clearUpdateBuffer(); 3453 lastCurrentRow = currentRow; 3454 beforeFirst = false; 3455 afterLast = false; 3456 currentRow = 0; 3457 } 3458 3459 private void clearUpdateBuffer() throws SQLException { 3460 if (concurrency == CONCUR_UPDATABLE) 3461 rowModifier.cancelRowUpdates(); 3462 } 3463 } 3464 3465 3468 3469 class RowModifier implements DataOperationListener { 3470 RecordBuffer recordBuffer; 3471 boolean readyToUpdate = false; 3472 3473 RowModifier() { 3474 recordBuffer = new RecordBuffer(); 3475 } 3476 3477 Object getObject(int columnIndex) throws SQLException { 3478 return recordBuffer.getColumnValue(columnIndex); 3479 } 3480 3481 void updateObject(int columnIndex, Object columnValue) throws SQLException { 3482 recordBuffer.setUpdateValue(columnIndex, columnValue); 3483 readyToUpdate = true; 3484 } 3485 3486 void cancelRowUpdates() throws SQLException { 3487 recordBuffer.clearData(); 3488 readyToUpdate = false; 3489 } 3490 3491 void updateInitiate() throws SQLException { 3492 int[] columnIndexes = recordBuffer.getUpdatedColumns(); 3493 Object [] columnValues = recordBuffer.getUpdatedValues(); 3494 synchronized (connection) { 3495 if (columnIndexes != null) { 3496 bufferIterator.updateInitiate(columnIndexes, columnValues); 3497 } 3498 readyToUpdate = false; 3499 try { 3500 if (statement.connection.getAutoCommit()) 3501 connection.getServerConnection().commit(); 3502 3503 } 3504 catch (DException ex) { 3505 throw ex.getSqlException(connection.getLocale()); 3506 } 3507 } 3508 } 3509 3510 void insertInitiate() throws SQLException { 3511 int[] columnIndexes = recordBuffer.getUpdatedColumns(); 3512 Object [] columnValues = recordBuffer.getUpdatedValues(); 3513 synchronized (connection) { 3514 try { 3515 bufferIterator.insertInitiate(columnIndexes, columnValues); 3516 if (statement.connection.getAutoCommit()) 3517 connection.getServerConnection().commit(); 3518 3519 } catch (DException de) { 3520 throw de.getSqlException(connection.getLocale()); 3521 } 3522 } 3523 } 3524 3525 void deleteInitiate() throws SQLException { 3526 synchronized (connection) { 3527 try { 3528 bufferIterator.deleteInitiate(); 3529 if (statement.connection.getAutoCommit()) 3530 connection.getServerConnection().commit(); 3531 } catch (DException de) { 3532 throw de.getSqlException(connection.getLocale()); 3533 } 3534 } 3535 } 3536 3537 3538 3539 boolean rowUpdated() throws SQLException { 3540 _Record currentRecord = (_Record) bufferIterator.getCurrent(); 3541 return recordBuffer.rowUpdated(currentRecord.getIdentity()); 3542 } 3543 3544 3545 boolean rowDeleted() throws SQLException { 3546 return false; 3547 } 3548 3549 boolean rowInserted() throws SQLException { 3550 _Record currentRecord = (_Record) bufferIterator.getCurrent(); 3551 return recordBuffer.rowInserted(currentRecord.getIdentity()); 3552 } 3553 3554 public void operationPerformed(DataOperation dataOperation) { 3555 int operationtype = dataOperation.operationType; 3556 Object key = dataOperation.recordIdentity; 3557 if (operationtype == dataOperation.INSERT) 3558 recordBuffer.addRowInserted(key); 3559 if (operationtype == dataOperation.DELETE) 3560 recordBuffer.removeRowDeleted(key); 3561 if (operationtype == dataOperation.UPDATE) 3562 recordBuffer.addRowUpdated(key); 3563 } 3564 } 3565 3566 private Calendar setCalendarAttributes(Calendar calendar, Date date) { 3567 Timestamp timestamp = new Timestamp(date.getTime()); 3568 calendar.clear(); 3569 calendar.set(Calendar.YEAR, timestamp.getYear() + 1900); 3570 calendar.set(Calendar.MONTH, timestamp.getMonth()); 3571 calendar.set(Calendar.DATE, timestamp.getDate()); 3572 calendar.set(Calendar.HOUR, timestamp.getHours()); 3573 calendar.set(Calendar.MINUTE, timestamp.getMinutes()); 3574 calendar.set(Calendar.SECOND, timestamp.getSeconds()); 3575 calendar.set(Calendar.MILLISECOND, timestamp.getNanos() / 0xf4240); 3576 return calendar; 3577 } 3578} 3579 | Popular Tags |