/** * Returns the value of the specified column as an input stream. * * @param columnLabel the column label * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public InputStream getBinaryStream(String columnLabel) throws SQLException { try { debugCodeCall("getBinaryStream", columnLabel); return get(columnLabel).getInputStream(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the input stream. * * @return the input stream * @throws SQLException */ @Override public InputStream getBinaryStream() throws SQLException { try { debugCodeCall("getBinaryStream"); checkClosed(); return value.getInputStream(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns the value of the specified column as an input stream. * * @param columnIndex (1,2,...) * @return the value * @throws SQLException if the column is not found or if the result set is * closed */ @Override public InputStream getBinaryStream(int columnIndex) throws SQLException { try { debugCodeCall("getBinaryStream", columnIndex); return get(columnIndex).getInputStream(); } catch (Exception e) { throw logAndConvert(e); } }
/** * Returns some bytes of the object. * * @param pos the index, the first byte is at position 1 * @param length the number of bytes * @return the bytes, at most length bytes * @throws SQLException */ @Override public byte[] getBytes(long pos, int length) throws SQLException { try { if (isDebugEnabled()) { debugCode("getBytes(" + pos + ", " + length + ");"); } checkClosed(); ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream in = value.getInputStream(); try { IOUtils.skipFully(in, pos - 1); IOUtils.copy(in, out, length); } finally { in.close(); } return out.toByteArray(); } catch (Exception e) { throw logAndConvert(e); } }
case Value.BLOB: { byte[] bytes = new byte[lobBlockSize]; InputStream input = v.getInputStream(); try { for (int i = 0;; i++) {
/** * Returns the length. * * @return the length * @throws SQLException */ @Override public long length() throws SQLException { try { debugCodeCall("length"); checkClosed(); if (value.getType() == Value.BLOB) { long precision = value.getPrecision(); if (precision > 0) { return precision; } } return IOUtils.copyAndCloseInput(value.getInputStream(), null); } catch (Exception e) { throw logAndConvert(e); } }
long written = IOUtils.copyAndCloseInput(v.getInputStream(), out); if (written != length) { throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, "length:" + length + " written:" + written);