Package org.postgresql.largeobject

Examples of org.postgresql.largeobject.LargeObject


    }

    public synchronized OutputStream setBinaryStream(long pos) throws SQLException
    {
        assertPosition(pos);
        LargeObject subLO = getLo(true).copy();
        subLOs.add(subLO);
        subLO.seek((int)(pos-1));
        return subLO.getOutputStream();
    }
View Full Code Here


      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);
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 8.3
                // in 8.3 this methos 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

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

                conn.setAutoCommit(false);
                LargeObjectManager lom = getLargeObjectManager(conn);
                // 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

            int oid = res.getInt(1);
            if (oid != -1) {
                conn.setAutoCommit(false);
                LargeObjectManager lom = getLargeObjectManager(conn);
                if (ob != null) {
                    LargeObject lo = lom.open(oid, LargeObjectManager.WRITE);
                    OutputStream os = lo.getOutputStream();
                    long size = copy((InputStream) ob, os);
                    lo.truncate((int) size);
                    lo.close();
                } else {
                    lom.delete(oid);
                    row.setInt(col, -1);
                }
            } else {
                if (ob != null) {
                    conn.setAutoCommit(false);
                    LargeObjectManager lom = getLargeObjectManager(conn);
                    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

    public OutputStreamBlob create() throws BlobException {
        try {
            Connection conn = DataSourceUtils.doGetConnection(dataSource);
            LargeObjectManager manager = extractManager(conn);
            long oid = manager.createLO(LargeObjectManager.WRITE);
            LargeObject lob = manager.open(oid, LargeObjectManager.WRITE);
            return new ServerSideOutputStreamBlob(oid, lob.getOutputStream(), compressor);
        } catch (Exception e) {
            throw e instanceof BlobException ? (BlobException) e : new BlobException("Cannot create blob", e);
        }
    }
View Full Code Here

    @Override
    public InputStreamBlob load(long id) throws BlobException {
        try {
            Connection conn = DataSourceUtils.doGetConnection(dataSource);
            LargeObjectManager manager = extractManager(conn);
            LargeObject lob = manager.open(id, LargeObjectManager.READ);
            return new ServerSideInputStreamBlob(id, lob.getInputStream(), compressor);
        } catch (Exception e) {
            throw e instanceof BlobException ? (BlobException) e : new BlobException("Cannot load blob, id: [" + id + "]", e);
        }
    }
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.