private void updateBlob(Connection connection, String findMessageByIdStatement, long sequence, byte[] data) throws SQLException, IOException { PreparedStatement s = null; ResultSet rs = null; try { s = connection.prepareStatement(statements.getFindMessageByIdStatement(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); s.setLong(1, sequence); rs = s.executeQuery(); if (!rs.next()) { throw new IOException("Failed select blob for message: " + sequence + " in container."); } // Update the blob Blob blob = rs.getBlob(1); blob.truncate(0); blob.setBytes(1, data); rs.updateBlob(1, blob); rs.updateRow(); // Update the row with the updated blob } finally { close(rs); close(s); } }
public static void updateBlobColumn(Connection con, String table, String blobColumn, byte[] inputBytes, String idColumn, Long id) throws SQLException { PreparedStatement pStmt = null; ResultSet rs = null; try { String sql = " SELECT " + blobColumn + " FROM " + table + " WHERE " + idColumn + " = ? " + " FOR UPDATE"; pStmt = con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); pStmt.setLong(1, id); rs = pStmt.executeQuery(); if (rs.next()) { Blob blob = rs.getBlob(blobColumn); blob.truncate(0); blob.setBytes(1, inputBytes); rs.updateBlob(blobColumn, blob); rs.updateRow(); } } finally { if(rs != null) rs.close(); if(pStmt != null) pStmt.close(); } }
@Override public Void call() throws SQLException { blob.truncate(len); return null; } });
/** * {@inheritDoc} */ @Override public void truncate(long len) throws SQLException { this.blob.truncate(len); }
/** * @see java.sql.Blob#truncate(long) */ public void truncate(long len) throws SQLException { this.reference.truncate(len); }
/** * @see java.sql.Blob#truncate(long) */ public void truncate(long len) throws SQLException { this.reference.truncate(len); }
/** * {@inheritDoc} */ @Override public void truncate(long len) throws SQLException { this.blob.truncate(len); }
/** * {@inheritDoc} */ @Override public void truncate(long len) throws SQLException { this.blob.truncate(len); }
@Override public void truncate(final long length) { try { blob.truncate(length); } catch (SQLException e) { // TODO Auto-generated catch block throw new RuntimeException(e); } }
@Override public void truncate(long len) throws SQLException { try { blob.truncate(len); } catch (SQLException e) { throw new UcanaccessSQLException(e); } }
@Override public void truncate(final long length) { close(); try { blob.truncate(length); } catch (SQLException e) { // TODO Auto-generated catch block throw new RuntimeException(e); } }
/** * truncates the Blob value represented by LOCATOR to have a length * of length. * * @param LOCATOR an integer that represents the LOCATOR used to retrieve an * instance of the LOB. * @param length an integer that represents the length to which the Blob * must be truncated to. * @throws SQLException */ public static void BLOBTRUNCATE(int LOCATOR, long length) throws SQLException { getBlobObjectCorrespondingtoLOCATOR(LOCATOR).truncate(length); }
/** * truncates the Blob value represented by LOCATOR to have a length * of length. * * @param LOCATOR an integer that represents the LOCATOR used to retrieve an * instance of the LOB. * @param length an integer that represents the length to which the Blob * must be truncated to. * @throws SQLException */ public static void BLOBTRUNCATE(int LOCATOR, long length) throws SQLException { getBlobObjectCorrespondingtoLOCATOR(LOCATOR).truncate(length); }
/** * truncates the Blob value represented by LOCATOR to have a length * of length. * * @param LOCATOR an integer that represents the LOCATOR used to retrieve an * instance of the LOB. * @param length an integer that represents the length to which the Blob * must be truncated to. * @throws SQLException */ public static void BLOBTRUNCATE(int LOCATOR, long length) throws SQLException { getBlobObjectCorrespondingtoLOCATOR(LOCATOR).truncate(length); }
public void truncate(long len) throws SQLException { getWrappedBlob().truncate(len); }
public void truncate(long len) throws SQLException { getWrappedBlob().truncate(len); }
public void truncate(long len) throws SQLException { getWrappedBlob().truncate(len) ; }
/** * Generates an Output stream that writes to a blob, also truncating the existing blob if required.<p> * * Apparently Oracle requires some non-standard handling here.<p> * * @param res the result set where the blob is located in * @param name the name of the database column where the blob is located * @return an Output stream from a blob * @throws SQLException if something goes wring */ public static OutputStream getOutputStreamFromBlob(ResultSet res, String name) throws SQLException { Blob blob = res.getBlob(name); blob.truncate(0); return blob.setBinaryStream(0L); }
public void setLength(long length) throws PersistException { // FIXME: Add special code to support increasing length try { getInternalBlobForPersist().truncate(length); } catch (SQLException e) { throw mRepo.toPersistException(e); } }
public void setLength(long length) throws PersistException { // FIXME: Add special code to support increasing length try { getInternalBlobForPersist().truncate(length); } catch (SQLException e) { throw mRepo.toPersistException(e); } }