private void buildConfig(final ResultSet rs, final long docId) throws SQLException {
      final long docOid = rs.getLong("DOC_OID");
      final Timestamp versionFrom = rs.getTimestamp("VER_FROM_INSTANT");
      final Timestamp versionTo = rs.getTimestamp("VER_TO_INSTANT");
      final Timestamp correctionFrom = rs.getTimestamp("CORR_FROM_INSTANT");
      final Timestamp correctionTo = rs.getTimestamp("CORR_TO_INSTANT");
      UniqueId uniqueId = createUniqueId(docOid, docId);

      ManageableMarketDataSnapshot marketDataSnapshot;
      // PLAT-1378
      if (_includeData) {
        LobHandler lob = getDialect().getLobHandler();
        byte[] bytes = lob.getBlobAsBytes(rs, "DETAIL");
        marketDataSnapshot =
            FUDGE_CONTEXT.readObject(
                ManageableMarketDataSnapshot.class, new ByteArrayInputStream(bytes));
        if (!_includeData) {
          marketDataSnapshot.setGlobalValues(null);
          marketDataSnapshot.setYieldCurves(null);
        }
      } else {
        marketDataSnapshot = new ManageableMarketDataSnapshot();
        marketDataSnapshot.setName(rs.getString("NAME"));
        marketDataSnapshot.setUniqueId(uniqueId);
      }
      MarketDataSnapshotDocument doc = new MarketDataSnapshotDocument();
      doc.setUniqueId(uniqueId);
      doc.setVersionFromInstant(DbDateUtils.fromSqlTimestamp(versionFrom));
      doc.setVersionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(versionTo));
      doc.setCorrectionFromInstant(DbDateUtils.fromSqlTimestamp(correctionFrom));
      doc.setCorrectionToInstant(DbDateUtils.fromSqlTimestampNullFarFuture(correctionTo));
      doc.setSnapshot(marketDataSnapshot);
      _documents.add(doc);
    }
  @Test
  public void testCreatingPreparedStatementCallback() throws SQLException {
    LobHandler handler = mock(LobHandler.class);
    LobCreator creator = mock(LobCreator.class);
    PreparedStatement ps = mock(PreparedStatement.class);

    given(handler.getLobCreator()).willReturn(creator);
    given(ps.executeUpdate()).willReturn(3);

    class SetValuesCalled {
      boolean b = false;
    }

    final SetValuesCalled svc = new SetValuesCalled();

    AbstractLobCreatingPreparedStatementCallback psc =
        new AbstractLobCreatingPreparedStatementCallback(handler) {
          @Override
          protected void setValues(PreparedStatement ps, LobCreator lobCreator)
              throws SQLException, DataAccessException {
            svc.b = true;
          }
        };

    assertEquals(Integer.valueOf(3), psc.doInPreparedStatement(ps));
    assertTrue(svc.b);
    verify(creator).close();
    verify(handler).getLobCreator();
    verify(ps).executeUpdate();
  }
  @Override
  protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler)
      throws SQLException {

    StringBuffer read_data = new StringBuffer("");
    int read_length;

    char[] buf = new char[1024];

    Reader rd = lobHandler.getClobAsCharacterStream(rs, index);
    try {
      while ((read_length = rd.read(buf)) != -1) {
        read_data.append(buf, 0, read_length);
      }
    } catch (IOException ie) {
      LOGGER.debug("ie: {}", ie);
    } finally {
      if (rd != null) {
        try {
          rd.close();
        } catch (Exception ignore) {
          LOGGER.debug("IGNORE: {}", ignore.getMessage());
        }
      }
    }

    return read_data.toString();
  }
Esempio n. 4
0
  @Override
  public SaveGameDTO mapRow(ResultSet rs, int rowNum) throws SQLException {

    SaveGameDTO dto = new SaveGameDTO();
    dto.setId(rs.getInt(1));
    dto.setName(rs.getString(2));
    dto.setActivePlayer(rs.getInt(3));
    dto.setPhase(rs.getInt(4));
    dto.setSelectTile(StringUtils.stringToStileDTO(rs.getString(5)));
    dto.setAiPlayer(rs.getInt(6));
    dto.setAiDifficulty(rs.getInt(7));
    dto.setBoardState(rs.getString(8));
    dto.setTextAreaText(lobHandler.getClobAsString(rs, 9));
    return dto;
  }
Esempio n. 5
0
 @Override
 protected Object getResultInternal(ResultSet rs, int index, LobHandler lobHandler)
     throws SQLException {
   return lobHandler.getBlobAsBytes(rs, index);
 }
  @Override
  protected Object nullSafeGetInternal(
      ResultSet rs, String[] names, Object owner, LobHandler lobHandler) throws SQLException {

    return lobHandler.getBlobAsBytes(rs, names[0]);
  }