/** * <p>Sets the current position within the object.</p> * * <p>This is similar to the fseek() call in the standard C library. It allows you to have random * access to the large object.</p> * * @param pos position within object from beginning * @throws SQLException if a database-access error occurs. */ public void seek(int pos) throws SQLException { seek(pos, SEEK_SET); }
/** * Repositions this stream to the position at the time the <code>mark</code> method was last * called on this input stream. NB: If mark is not called we move to the beginning. * * @see java.io.InputStream#mark(int) * @see java.io.IOException */ public synchronized void reset() throws IOException { checkClosed(); try { if (mpos <= Integer.MAX_VALUE) { lo.seek((int)mpos); } else { lo.seek64(mpos, LargeObject.SEEK_SET); } buffer = null; apos = mpos; } catch (SQLException se) { throw new IOException(se.toString()); } }
public LOIterator(long start) throws SQLException { lo.seek((int) start); }
public synchronized java.io.InputStream getBinaryStream(long pos, long length) throws SQLException { checkFreed(); LargeObject subLO = getLo(false).copy(); addSubLO(subLO); if (pos > Integer.MAX_VALUE) { subLO.seek64(pos - 1, LargeObject.SEEK_SET); } else { subLO.seek((int) pos - 1, LargeObject.SEEK_SET); } return subLO.getInputStream(length); }
/** * Sets the current position within the object. * * <p>This is similar to the fseek() call in the standard C library. It * allows you to have random access to the large object. * * @param pos position within object from begining * @exception SQLException if a database-access error occurs. */ public void seek(int pos) throws SQLException { seek(pos, SEEK_SET); }
LOIterator(long start) throws SQLException { getLo(false).seek((int) start); }
/** * <p>This method is inefficient, as the only way to find out the size of the object is to seek to * the end, record the current position, then return to the original position.</p> * * <p>A better method will be found in the future.</p> * * @return the size of the large object * @throws SQLException if a database-access error occurs. */ public int size() throws SQLException { int cp = tell(); seek(0, SEEK_END); int sz = tell(); seek(cp, SEEK_SET); return sz; }
/** * This method is inefficient, as the only way to find out the size of * the object is to seek to the end, record the current position, then * return to the original position. * * <p>A better method will be found in the future. * * @return the size of the large object * @exception SQLException if a database-access error occurs. */ public int size() throws SQLException { int cp = tell(); seek(0, SEEK_END); int sz = tell(); seek(cp, SEEK_SET); return sz; }
/** * Repositions this stream to the position at the time the * <code>mark</code> method was last called on this input stream. * NB: If mark is not called we move to the begining. * @see java.io.InputStream#mark(int) * @see java.io.IOException */ public synchronized void reset() throws IOException { checkClosed(); try { lo.seek(mpos); } catch (SQLException se) { throw new IOException(se.toString()); } }
public synchronized String getSubString(long i, int j) throws SQLException { assertPosition(i, j); lo.seek((int)i - 1); return new String(lo.read(j)); }
public synchronized byte[] getBytes(long pos, int length) throws SQLException { assertPosition(pos); lo.seek((int)(pos-1), LargeObject.SEEK_SET); return lo.read(length); }
public synchronized OutputStream setBinaryStream(long pos) throws SQLException { assertPosition(pos); LargeObject subLO = lo.copy(); subLOs.add(subLO); subLO.seek((int)(pos-1)); return subLO.getOutputStream(); }
public synchronized InputStream getBinaryStream() throws SQLException { checkFreed(); LargeObject subLO = lo.copy(); subLOs.add(subLO); subLO.seek(0, LargeObject.SEEK_SET); return subLO.getInputStream(); }
public synchronized String getSubString(long i, int j) throws SQLException { assertPosition(i, j); getLo(false).seek((int) i - 1); return new String(getLo(false).read(j)); }
/** * Writes all or part of the given <code>byte</code> array to the * <code>BLOB</code> value that this <code>Blob</code> object represents * and returns the number of bytes written. * Writing starts at position <code>pos</code> in the <code>BLOB</code> * value; <code>len</code> bytes from the given byte array are written. * * @param pos the position in the <code>BLOB</code> object at which * to start writing * @param bytes the array of bytes to be written to this <code>BLOB</code> * object * @param offset the offset into the array <code>bytes</code> at which * to start reading the bytes to be set * @param len the number of bytes to be written to the <code>BLOB</code> * value from the array of bytes <code>bytes</code> * @return the number of bytes written * @exception SQLException if there is an error accessing the * <code>BLOB</code> value * @see #getBytes * @since 1.4 */ public synchronized int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { assertPosition(pos); lo.seek((int) (pos-1)); lo.write(bytes, offset, len); return len; }
public synchronized int setBytes(long pos, byte[] bytes, int offset, int len) throws SQLException { assertPosition(pos); getLo(true).seek((int) (pos - 1)); getLo(true).write(bytes, offset, len); return len; } }
public synchronized byte[] getBytes(long pos, int length) throws SQLException { assertPosition(pos); getLo(false).seek((int) (pos - 1), LargeObject.SEEK_SET); return getLo(false).read(length); }
protected synchronized LargeObject getLo(boolean forWrite) throws SQLException { if (this.currentLo != null) { if (forWrite && !currentLoIsWriteable) { // Reopen the stream in read-write, at the same pos. int currentPos = this.currentLo.tell(); LargeObjectManager lom = conn.getLargeObjectAPI(); LargeObject newLo = lom.open(oid, LargeObjectManager.READWRITE); this.subLOs.add(this.currentLo); this.currentLo = newLo; if (currentPos != 0) { this.currentLo.seek(currentPos); } } return this.currentLo; } LargeObjectManager lom = conn.getLargeObjectAPI(); currentLo = lom.open(oid, forWrite ? LargeObjectManager.READWRITE : LargeObjectManager.READ); currentLoIsWriteable = forWrite; return currentLo; }
public synchronized InputStream getBinaryStream() throws SQLException { checkFreed(); LargeObject subLO = getLo(false).copy(); addSubLO(subLO); subLO.seek(0, LargeObject.SEEK_SET); return subLO.getInputStream(); }
public synchronized OutputStream setBinaryStream(long pos) throws SQLException { assertPosition(pos); LargeObject subLO = getLo(true).copy(); addSubLO(subLO); subLO.seek((int) (pos - 1)); return subLO.getOutputStream(); }