Examples of LargeObjectManager


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

Examples of org.postgresql.largeobject.LargeObjectManager

            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

Examples of org.postgresql.largeobject.LargeObjectManager

                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

Examples of org.postgresql.largeobject.LargeObjectManager

                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

Examples of org.postgresql.largeobject.LargeObjectManager

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

Examples of org.postgresql.largeobject.LargeObjectManager

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

Examples of org.postgresql.largeobject.LargeObjectManager

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

Examples of org.postgresql.largeobject.LargeObjectManager

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

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 = ((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

Examples of org.postgresql.largeobject.LargeObjectManager

            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
Copyright © 2018 www.massapi.com. 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.