public static void close(Blob x) { if (x == null) { return; } try { x.free(); } catch (Exception e) { LOG.debug("close error", e); } }
@Override public void close() throws IOException { try { delegate.close(); } finally { try { source.free(); } catch (SQLException ex) { throw new IOException(ex); } } }
@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); } } }
@Override public void close() throws IOException { try { delegate.close(); } finally { try { source.free(); } catch (SQLException ex) { throw new IOException(ex); } } }
//(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();
/** * 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(); } }
Blob blob = rs.getBlob(i); provider.defaultSerializeValue(blob.getBinaryStream(), jgen); blob.free(); break;
for ( Blob blob : blobs ) { try { blob.free();
blob.free(); } else { rec.put(i - 1, null);
@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() ); }
@Override public void close() throws IOException { try { is.close(); } finally { try { blob.free(); } catch (SQLException e) { log.debug(e.getMessage()); } } } };
public static void close(Blob x) { if (x == null) { return; } try { x.free(); } catch (Exception e) { LOG.debug("close error", e); } }
/** * 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); } }
assertTrue( nclob instanceof WrappedClob ); blob.free(); clob.free(); nclob.free();
b.free(); } catch (Throwable ignore){
if (blob != null) { try { blob.free(); } catch (SQLException|UnsupportedOperationException e) {
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));
@Override public void free() throws SQLException { try { blob.free(); } catch (SQLException e) { throw new UcanaccessSQLException(e); } }