java.sql.Blob.free()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中java.sql.Blob.free()方法的一些代码示例,展示了Blob.free()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.free()方法的具体详情如下:
包路径:java.sql.Blob
类名称:Blob
方法名:free

Blob.free介绍

[英]Frees any resources held by this blob. After free is called, calling method other than free will throw SQLException (calling freerepeatedly will do nothing).
[中]释放此blob所持有的任何资源。调用free后,调用free以外的方法将抛出SQLException(重复调用free将不起任何作用)。

代码示例

代码示例来源:origin: alibaba/druid

public static void close(Blob x) {
  if (x == null) {
    return;
  }
  try {
    x.free();
  } catch (Exception e) {
    LOG.debug("close error", e);
  }
}

代码示例来源:origin: quartz-scheduler/quartz

@Override
public void close() throws IOException {
  try {
    delegate.close();
  } finally {
    try {
      source.free();
    } catch (SQLException ex) {
      throw new IOException(ex);
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void close() {
  for (Blob blob : this.temporaryBlobs) {
    try {
      blob.free();
    }
    catch (SQLException ex) {
      logger.warn("Could not free BLOB", ex);
    }
  }
  for (Clob clob : this.temporaryClobs) {
    try {
      clob.free();
    }
    catch (SQLException ex) {
      logger.warn("Could not free CLOB", ex);
    }
  }
}

代码示例来源:origin: quartz-scheduler/quartz

@Override
public void close() throws IOException {
  try {
    delegate.close();
  } finally {
    try {
      source.free();
    } catch (SQLException ex) {
      throw new IOException(ex);
    }
  }
}

代码示例来源:origin: stackoverflow.com

//(assuming you have a ResultSet named RS)
Blob blob = rs.getBlob("SomeDatabaseField");

int blobLength = (int) blob.length();  
byte[] blobAsBytes = blob.getBytes(1, blobLength);

//release the blob and free up memory. (since JDBC 4.0)
blob.free();

代码示例来源:origin: quartz-scheduler/quartz

blob.free();

代码示例来源:origin: quartz-scheduler/quartz

blob.free();

代码示例来源:origin: apache/geode

/**
 * If the given column contains a Blob returns its data as a byte array;
 * otherwise return null.
 *
 * @throws JdbcConnectorException if blob is too big to fit in a byte array
 */
private byte[] getBlobData(int columnIndex) throws SQLException {
 Blob blob = resultSet.getBlob(columnIndex);
 if (blob == null) {
  return null;
 }
 try {
  long blobLength = blob.length();
  if (blobLength > Integer.MAX_VALUE) {
   throw new JdbcConnectorException(
     "Blob of length " + blobLength + " is too big to be converted to a byte array.");
  }
  return blob.getBytes(1, (int) blobLength);
 } finally {
  blob.free();
 }
}

代码示例来源:origin: stackoverflow.com

Blob blob = rs.getBlob(i);
provider.defaultSerializeValue(blob.getBinaryStream(), jgen);
blob.free();
break;

代码示例来源:origin: hibernate/hibernate-orm

for ( Blob blob : blobs ) {
  try {
    blob.free();

代码示例来源:origin: apache/nifi

blob.free();
} else {
  rec.put(i - 1, null);

代码示例来源:origin: hibernate/hibernate-orm

@Test
public void testLobCreation() throws SQLException {
  Session session = sessionFactory().getCurrentSession();
  session.beginTransaction();
  Blob blob = Hibernate.getLobCreator( session ).createBlob( new byte[] {} );
  blob.free();
  Clob clob = Hibernate.getLobCreator( session ).createClob( "Steve" );
  clob.free();
  session.getTransaction().commit();
  assertFalse( session.isOpen() );
}

代码示例来源:origin: davidmoten/rxjava-jdbc

@Override
  public void close() throws IOException {
    try {
      is.close();
    } finally {
      try {
        blob.free();
      } catch (SQLException e) {
        log.debug(e.getMessage());
      }
    }
  }
};

代码示例来源:origin: com.alibaba/druid

public static void close(Blob x) {
  if (x == null) {
    return;
  }
  try {
    x.free();
  } catch (Exception e) {
    LOG.debug("close error", e);
  }
}

代码示例来源:origin: davidmoten/rxjava-jdbc

/**
 * Returns the bytes of a {@link Blob} and frees the blob resource.
 * 
 * @param b
 *            blob
 * @return
 */
private static byte[] toBytes(Blob b) {
  try {
    InputStream is = b.getBinaryStream();
    byte[] result = IOUtils.toByteArray(is);
    is.close();
    b.free();
    return result;
  } catch (IOException e) {
    throw new RuntimeException(e);
  } catch (SQLException e) {
    throw new SQLRuntimeException(e);
  }
}

代码示例来源:origin: hibernate/hibernate-orm

assertTrue( nclob instanceof WrappedClob );
blob.free();
clob.free();
nclob.free();

代码示例来源:origin: aaberg/sql2o

b.free();
} catch (Throwable ignore){

代码示例来源:origin: apache/tika

if (blob != null) {
  try {
    blob.free();
  } catch (SQLException|UnsupportedOperationException e) {

代码示例来源:origin: stackoverflow.com

Blob blob = rs.getBlob("img");
int blobLength = (int) blob.length();  

byte[] bytes = blob.getBytes(1, blobLength);
blob.free();
BufferedImage img = ImageIO.read(new ByteArrayInputStream(bytes));

代码示例来源:origin: net.sf.ucanaccess/ucanaccess

@Override
public void free() throws SQLException {
  try {
    blob.free();
  } catch (SQLException e) {
    throw new UcanaccessSQLException(e);
  }
}

相关文章