Package org.postgresql.largeobject

Examples of org.postgresql.largeobject.LargeObject


    @Override
    public DetachedBlob detach(long id) throws BlobException {
        try {
            Connection conn = DataSourceUtils.doGetConnection(dataSource);
            LargeObjectManager manager = extractManager(conn);
            LargeObject lob = manager.open(id, LargeObjectManager.READ);
            return new TempFileDetachedBlob(id, lob.getInputStream(), compressor);
        } catch (Exception e) {
            throw e instanceof BlobException ? (BlobException) e : new BlobException("Cannot detach blob, id: [" + id + "]", e);
        }
    }
View Full Code Here


            .getConnection();
        conn.setAutoCommit(false);
        LargeObjectManager lom = ((PGConnection)conn.getInnermostDelegate())
        .getLargeObjectAPI();
        if (rs.getInt(column) != -1) {
            LargeObject lo = lom.open(rs.getInt(column));
            return lo.getInputStream();
        } else {
            return null;
        }
    }
View Full Code Here

                PGConnection pgconn = (PGConnection)conn.getInnermostDelegate();
                LargeObjectManager lom = pgconn.getLargeObjectAPI();
                // The create method is valid in versions previous to 8.3
                // in 8.3 this method is deprecated, use createLO
                int oid = lom.create();
                LargeObject lo = lom.open(oid, LargeObjectManager.WRITE);
                OutputStream os = lo.getOutputStream();
                copy((InputStream)ob, os);
                lo.close();
                row.setInt(col, oid);
            } catch (IOException ioe) {
                throw new StoreException(ioe);
            } finally {
                conn.close();
View Full Code Here

                conn.setAutoCommit(false);
                PGConnection pgconn = (PGConnection)conn
                    .getInnermostDelegate();
                LargeObjectManager lom = pgconn.getLargeObjectAPI();
                if (ob != null) {
                    LargeObject lo = lom.open(oid, LargeObjectManager.WRITE);
                    OutputStream os = lo.getOutputStream();
                    copy((InputStream)ob, os);
                    lo.close();
                } else {
                    lom.delete(oid);
                    row.setInt(col, -1);
                }
            } else {
                if (ob != null) {
                    conn.setAutoCommit(false);
                    PGConnection pgconn = (PGConnection)conn
                        .getInnermostDelegate();
                    LargeObjectManager lom = pgconn.getLargeObjectAPI();
                    oid = lom.create();
                    LargeObject lo = lom.open(oid, LargeObjectManager.WRITE);
                    OutputStream os = lo.getOutputStream();
                    copy((InputStream)ob, os);
                    lo.close();
                    row.setInt(col, oid);
                }
            }

        } catch (IOException ioe) {
View Full Code Here

            lo.close();
            lo = null;
        }
        Iterator i = subLOs.iterator();
        while (i.hasNext()) {
            LargeObject subLO = (LargeObject)i.next();
            subLO.close();
        }
        subLOs = null;
    }
View Full Code Here


    public synchronized InputStream getBinaryStream() throws SQLException
    {
        checkFreed();
        LargeObject subLO = lo.copy();
        subLOs.add(subLO);
        subLO.seek(0, LargeObject.SEEK_SET);
        return subLO.getInputStream();
    }
View Full Code Here

    }

    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();
    }
View Full Code Here

TOP

Related Classes of org.postgresql.largeobject.LargeObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.