Java 8 Blob - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Blob class.

This code example shows how to use the following methods: getBytes, length
	@Override 
	public byte[] getBlobAsBytes(ResultSet rs, int columnIndex) throws SQLException {
		logger.debug("Returning BLOB as bytes");
		if (this.wrapAsLob) {
			Blob blob = rs.getBlob(columnIndex);
			return blob.getBytes(1, (int) blob.length());
		} 
		else { 
			return rs.getBytes(columnIndex);
		} 
	} 
 
	@Override 
	public InputStream getBlobAsBinaryStream(ResultSet rs, int columnIndex) throws SQLException {
		logger.debug("Returning BLOB as binary stream");
		if (this.wrapAsLob) {
			Blob blob = rs.getBlob(columnIndex);
			return blob.getBinaryStream();
		} 
		else { 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getBinaryStream
    public Object get(ResultSet rs, String colName) throws SQLException {
        File f = this.createTempFile();
        Blob blob = rs.getBlob(colName);
        if (blob == null)
            return null; 
        Files.write(f, blob.getBinaryStream());
        return new SimpleBlob(f);
    } 
 
    public void set(PreparedStatement stat, Object obj, int i) throws SQLException {
        if (null == obj) {
            stat.setNull(i, Types.BLOB);
        } else { 
            Blob blob = (Blob) obj;
            stat.setBlob(i, blob);
        } 
    } 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: length
	 * @return String 
	 */ 
	private static String formatLogParam(Blob obj) {
		String result="";
		try { 
			result= "(blob of length "+obj.length()+")";
		} catch (SQLException e) {
			result = "(blob of unknown length)";
		} 
		return result;
	} 
 
	/** Formatter for debugging purposes only.  
	 * @param obj to print 
	 * @return String 
	 */ 
	private static String formatLogParam(Clob obj) {
		String result="";
		try { 
			result= "(cblob of length "+obj.length()+")";
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setBytes, truncate
                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);
        } 
    } 
 
    @Override 
    public byte[] doGetMessage(TransactionContext c, MessageId id) throws SQLException, IOException {
        PreparedStatement s = null;
        ResultSet rs = null;
        cleanupExclusiveLock.readLock().lock(); 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getBytes, length
  public byte[] getNullableResult(ResultSet rs, String columnName)
      throws SQLException {
    Blob blob = rs.getBlob(columnName);
    byte[] returnValue = null;
    if (null != blob) {
      returnValue = blob.getBytes(1, (int) blob.length());
    } 
    return returnValue;
  } 
 
  @Override 
  public byte[] getNullableResult(ResultSet rs, int columnIndex)
      throws SQLException {
    Blob blob = rs.getBlob(columnIndex);
    byte[] returnValue = null;
    if (null != blob) {
      returnValue = blob.getBytes(1, (int) blob.length());
    } 
    return returnValue;
  } 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 Blob Questions & Answers:

See Code Examples for Java 8 Blob Methods: