/** * Create a Blob value from this input stream. * * @param x the input stream * @param length the length (if smaller or equal than 0, all data until the * end of file is read) * @return the value */ public Value createBlob(InputStream x, long length) { if (x == null) { return ValueNull.INSTANCE; } if (length <= 0) { length = -1; } Value v = ValueLobDb.createTempBlob(x, length); session.addTemporaryLob(v); return v; }
@Override public Value convertPrecision(long precision, boolean force) { if (this.precision <= precision) { return this; } ValueLobDb lob; if (type == CLOB) { lob = ValueLobDb.createTempClob(getReader(), precision); } else { lob = ValueLobDb.createTempBlob(getInputStream(), precision); } return lob; }
v = (in == null) ? (Value) ValueNull.INSTANCE : ValueLobDb.createTempBlob(in, -1); break;
/** * Create a new empty Blob object. * * @return the object */ @Override public Blob createBlob() throws SQLException { try { int id = getNextId(TraceObject.BLOB); debugCodeAssign("Blob", TraceObject.BLOB, id, "createClob()"); checkClosed(); try { Value v = ValueLobDb.createTempBlob( new ByteArrayInputStream(Utils.EMPTY_BYTES), 0); session.addTemporaryLob(v); return new JdbcBlob(this, v, id); } finally { afterWriting(); } } catch (Exception e) { throw logAndConvert(e); } }
return ValueLobDb.createTempBlob((java.io.InputStream) x, -1); } else if (x instanceof java.sql.Blob) { try { return ValueLobDb.createTempBlob(((java.sql.Blob) x).getBinaryStream(), -1); } catch (SQLException e) { throw DbException.convert(e);
/** * Convert a lob to another data type. The data is fully read in memory * except when converting to BLOB or CLOB. * * @param t the new type * @return the converted value */ @Override public Value convertTo(int t) { if (t == type) { return this; } else if (t == Value.CLOB) { if (small != null) { return ValueLobDb.createSmallLob(t, small); } else { return ValueLobDb.createTempClob(getReader(), -1); } } else if (t == Value.BLOB) { if (small != null) { return ValueLobDb.createSmallLob(t, small); } else { return ValueLobDb.createTempBlob(getInputStream(), -1); } } return super.convertTo(t); }