/** * This opens an existing large object, based on its OID. This method assumes that READ and WRITE * access is required (the default). * * @param oid of large object * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(long oid) throws SQLException { return open(oid, READWRITE, false); }
/** * This opens an existing large object, same as previous method, but commits the transaction on * close if asked. * * @param oid of large object * @param commitOnClose commit the transaction when this LOB will be closed * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(long oid, boolean commitOnClose) throws SQLException { return open(oid, READWRITE, commitOnClose); }
/** * This opens an existing large object, based on its OID. * * @param oid of large object * @param mode mode of open * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(long oid, int mode) throws SQLException { return open(oid, mode, false); }
/** * This opens an existing large object, same as previous method, but commits the transaction on * close if asked. This is useful when the LOB is returned to a caller which won't take care of * transactions by itself. * * @param oid of large object * @param commitOnClose commit the transaction when this LOB will be closed * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(int oid, boolean commitOnClose) throws SQLException { return open((long) oid, commitOnClose); }
/** * This opens an existing large object, same as previous method, but commits the transaction on * close if asked. * * @param oid of large object * @param mode mode of open * @param commitOnClose commit the transaction when this LOB will be closed * @return LargeObject instance providing access to the object * @throws SQLException on error */ public LargeObject open(int oid, int mode, boolean commitOnClose) throws SQLException { return open((long) oid, mode, commitOnClose); }
/** * This opens an existing large object, based on its OID. This method * assumes that READ and WRITE access is required (the default). * * @param oid of large object * @return LargeObject instance providing access to the object * @exception SQLException on error */ public LargeObject open(long oid) throws SQLException { return open(oid, READWRITE); }
/** * This opens an existing large object, based on its OID. This method * assumes that READ and WRITE access is required (the default). * * @param oid of large object * @return LargeObject instance providing access to the object * @exception SQLException on error * @deprecated As of 8.3, replaced by {@link #open(long)} */ public LargeObject open(int oid) throws SQLException { return open((long)oid); }
/** * This opens an existing large object, based on its OID * * @param oid of large object * @param mode mode of open * @return LargeObject instance providing access to the object * @exception SQLException on error * @deprecated As of 8.3, replaced by {@link #open(long, int)} */ public LargeObject open(int oid, int mode) throws SQLException { return open((long)oid, mode); }
/** * This opens an existing large object, based on its OID. This method assumes that READ and WRITE * access is required (the default). * * @param oid of large object * @return LargeObject instance providing access to the object * @throws SQLException on error * @deprecated As of 8.3, replaced by {@link #open(long)} */ @Deprecated public LargeObject open(int oid) throws SQLException { return open((long) oid, false); }
/** * This opens an existing large object, based on its OID. * * @param oid of large object * @param mode mode of open * @return LargeObject instance providing access to the object * @throws SQLException on error * @deprecated As of 8.3, replaced by {@link #open(long, int)} */ @Deprecated public LargeObject open(int oid, int mode) throws SQLException { return open((long) oid, mode, false); }
public AbstractJdbc2BlobClob(BaseConnection conn, long oid) throws SQLException { this.conn = conn; LargeObjectManager lom = conn.getLargeObjectAPI(); this.lo = lom.open(oid); subLOs = new ArrayList(); }
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; }
protected long createBlob(int i, InputStream inputStream, long length) throws SQLException { LargeObjectManager lom = connection.getLargeObjectAPI(); long oid = lom.createLO(); LargeObject lob = lom.open(oid); OutputStream outputStream = lob.getOutputStream(); byte[] buf = new byte[4096];
LargeObjectManager lom = connection.getLargeObjectAPI(); long oid = lom.createLO(); LargeObject lob = lom.open(oid); OutputStream los = lob.getOutputStream(); byte[] buf = new byte[4096];
LargeObjectManager lom = connection.getLargeObjectAPI(); long oid = lom.createLO(); LargeObject lob = lom.open(oid); Charset connectionCharset = Charset.forName(connection.getEncoding().name()); OutputStream los = lob.getOutputStream();
LargeObjectManager lom = connection.getLargeObjectAPI(); long oid = lom.createLO(); LargeObject lob = lom.open(oid); OutputStream los = lob.getOutputStream(); try
LargeObject lob = lom.open(oid); OutputStream los = lob.getOutputStream(); try
public InputStream getBinaryStream(int columnIndex) throws SQLException { checkResultSet( columnIndex ); if (wasNullFlag) return null; if (connection.haveMinimumCompatibleVersion("7.2")) { //Version 7.2 supports BinaryStream for all PG bytea type //As the spec/javadoc for this method indicate this is to be used for //large binary values (i.e. LONGVARBINARY) PG doesn't have a separate //long binary datatype, but with toast the bytea datatype is capable of //handling very large values. Thus the implementation ends up calling //getBytes() since there is no current way to stream the value from the server byte b[] = getBytes(columnIndex); if (b != null) return new ByteArrayInputStream(b); } else { // In 7.1 Handle as BLOBS so return the LargeObject input stream if ( fields[columnIndex - 1].getOID() == Oid.OID) { LargeObjectManager lom = connection.getLargeObjectAPI(); LargeObject lob = lom.open(getLong(columnIndex)); return lob.getInputStream(); } } return null; }
public void setBytes(int parameterIndex, byte[] x) throws SQLException { checkClosed(); if (null == x) { setNull(parameterIndex, Types.VARBINARY); return ; } if (connection.haveMinimumCompatibleVersion("7.2")) { //Version 7.2 supports the bytea datatype for byte arrays byte[] copy = new byte[x.length]; System.arraycopy(x, 0, copy, 0, x.length); preparedParameters.setBytea( parameterIndex, copy, 0, x.length); } else { //Version 7.1 and earlier support done as LargeObjects LargeObjectManager lom = connection.getLargeObjectAPI(); long oid = lom.createLO(); LargeObject lob = lom.open(oid); lob.write(x); lob.close(); setLong(parameterIndex, oid); } }
LargeObject lob = lom.open(getLong(columnIndex)); byte buf[] = lob.read(lob.size()); lob.close();