//
  // Examine BLOBs and CLOBs.
  //
  private void vetLargeObjects(
      Connection conn, HashSet<String> unsupportedList, HashSet<String> notUnderstoodList)
      throws Exception {
    Statement stmt = conn.createStatement();

    stmt.execute("CREATE TABLE t (id INT PRIMARY KEY, " + "b BLOB(10), c CLOB(10))");
    stmt.execute(
        "INSERT INTO t (id, b, c) VALUES (1, "
            + "CAST ("
            + TestUtil.stringToHexLiteral("101010001101")
            + "AS BLOB(10)), CAST ('hello' AS CLOB(10)))");

    ResultSet rs = stmt.executeQuery("SELECT id, b, c FROM t");

    rs.next();

    Blob blob = rs.getBlob(2);
    Clob clob = rs.getClob(3);

    vetObject(blob, unsupportedList, notUnderstoodList);
    vetObject(clob, unsupportedList, notUnderstoodList);

    stmt.close();
    conn.rollback();
  }
예제 #2
0
    public CacheItemHolder mapRow(ResultSet rs, Connection connection) throws SQLException {
      URI uri = URI.create(rs.getString("uri"));
      Vary vary = convertToVary(rs.getString("vary"));
      Blob blob = rs.getBlob("payload");

      Payload payload = null;
      if (blob != null && !rs.wasNull()) {
        payload =
            new InputStreamPayload(
                new ResultSetInputStream(rs, connection, blob.getBinaryStream()),
                MIMEType.valueOf(rs.getString("mimetype")));
      }
      Status status = Status.valueOf(rs.getInt("status"));
      Headers headers = convertToHeaders(rs.getString("headers"));
      DateTime cacheTime = new DateTime(rs.getTimestamp("cachetime").getTime());
      HTTPResponse response = new HTTPResponse(payload, status, headers);
      return new CacheItemHolder(uri, vary, new CacheItem(rewriteResponse(response), cacheTime));
    }