Package org.postgresql.largeobject

Examples of org.postgresql.largeobject.LargeObjectManager


    public InputStream getLOBStream(JDBCStore store, ResultSet rs,
        int column) throws SQLException {
        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


            col.setType(Types.INTEGER);
            DelegatingConnection conn = (DelegatingConnection)store
            .getConnection();
            try {
                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) {
View Full Code Here

                throw new InternalException(_loc.get("stream-exception"));
            }
            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);
                }
View Full Code Here

                throw new InternalException(_loc.get("stream-exception"));
            }
            int oid = res.getInt(1);
            if (oid != -1) {
                conn.setAutoCommit(false);
                LargeObjectManager lom = getLargeObjectManager(conn);
                lom.delete(oid);
            }
        } finally {
            if (res != null)
                try { res.close (); } catch (SQLException e) {}
            if (stmnt != null)
View Full Code Here

     */
    @Override
    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

     */
    @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

     */
    @Override
    public void delete(long id) throws BlobException {
        try {
            Connection conn = DataSourceUtils.doGetConnection(dataSource);
            LargeObjectManager manager = extractManager(conn);
            manager.delete(id);
        } catch (Exception e) {
            throw e instanceof BlobException ? (BlobException) e : new BlobException("Cannot delete blob, id: [" + id + "]", e);
        }
    }
View Full Code Here

    public InputStream getLOBStream(JDBCStore store, ResultSet rs,
        int column) throws SQLException {
        DelegatingConnection conn = (DelegatingConnection)store
            .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

            DelegatingConnection conn = (DelegatingConnection)store
            .getConnection();
            try {
                conn.setAutoCommit(false);
                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) {
View Full Code Here

TOP

Related Classes of org.postgresql.largeobject.LargeObjectManager

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.