Package org.hsqldb.lib

Examples of org.hsqldb.lib.HsqlByteArrayOutputStream


        dataOut.writeInt(databaseID);
        dataOut.writeLong(sessionID);
        dataOut.writeLong(lobID);
        dataOut.writeInt(subType);

        HsqlByteArrayOutputStream byteArrayOS =
            new HsqlByteArrayOutputStream(bufferLength);

        byteArrayOS.reset();
        byteArrayOS.write(stream, bufferLength);
        dataOut.writeLong(currentOffset);
        dataOut.writeLong(byteArrayOS.size());
        dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

        currentOffset += byteArrayOS.size();

        if (byteArrayOS.size() < bufferLength) {
            return;
        }

        //
        while (true) {
            byteArrayOS.reset();
            byteArrayOS.write(stream, bufferLength);

            if (byteArrayOS.size() == 0) {
                break;
            }

            //
            dataOut.writeByte(mode);
            dataOut.writeInt(databaseID);
            dataOut.writeLong(sessionID);
            dataOut.writeLong(lobID);
            dataOut.writeInt(LobResultTypes.REQUEST_SET_BYTES);
            dataOut.writeLong(currentOffset);
            dataOut.writeLong(byteArrayOS.size());
            dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

            currentOffset += byteArrayOS.size();

            if (byteArrayOS.size() < bufferLength) {
                break;
            }
        }
    }
View Full Code Here


        dataOut.writeInt(databaseID);
        dataOut.writeLong(sessionID);
        dataOut.writeLong(lobID);
        dataOut.writeInt(subType);

        HsqlByteArrayOutputStream byteArrayOS =
            new HsqlByteArrayOutputStream(bufferLength);

        byteArrayOS.reset();
        byteArrayOS.write(reader, bufferLength / 2);

        //
        dataOut.writeLong(currentOffset);
        dataOut.writeLong(byteArrayOS.size() / 2);
        dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

        currentOffset += byteArrayOS.size() / 2;

        if (byteArrayOS.size() < bufferLength) {
            return;
        }

        //
        while (true) {
            byteArrayOS.reset();
            byteArrayOS.write(reader, bufferLength / 2);

            if (byteArrayOS.size() == 0) {
                break;
            }

            //
            dataOut.writeByte(mode);
            dataOut.writeInt(databaseID);
            dataOut.writeLong(sessionID);
            dataOut.writeLong(lobID);
            dataOut.writeInt(LobResultTypes.REQUEST_SET_CHARS);
            dataOut.writeLong(currentOffset);
            dataOut.writeLong(byteArrayOS.size() / 2);
            dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

            currentOffset += byteArrayOS.size() / 2;

            if (byteArrayOS.size() < bufferLength) {
                break;
            }
        }
    }
View Full Code Here

        if (x == null) {
            throw Util.sqlException(Trace.error(Trace.INVALID_JDBC_ARGUMENT,
                                                Trace.JDBC_NULL_STREAM));
        }

        HsqlByteArrayOutputStream out = null;

        try {
            out = new HsqlByteArrayOutputStream();

            int    size = 2048;
            byte[] buff = new byte[size];

            for (int left = length; left > 0; ) {
                int read = x.read(buff, 0, left > size ? size
                                                       : left);

                if (read == -1) {
                    break;
                }

                out.write(buff, 0, read);

                left -= read;
            }

            setParameter(parameterIndex, out.toByteArray());
        } catch (IOException e) {
            throw Util.sqlException(Trace.INPUTSTREAM_ERROR, e.toString());
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {}
            }
        }
    }
View Full Code Here

            String msg = "Maximum Blob input octet length exceeded: " + length;

            throw Util.sqlException(Trace.INPUTSTREAM_ERROR, msg);
        }

        HsqlByteArrayOutputStream out = null;

        try {
            out = new HsqlByteArrayOutputStream();

            java.io.InputStream in       = x.getBinaryStream();
            int                 buffSize = 2048;
            byte[]              buff     = new byte[buffSize];

            for (int left = (int) length; left > 0; ) {
                int read = in.read(buff, 0, left > buffSize ? buffSize
                                                            : left);

                if (read == -1) {
                    break;
                }

                out.write(buff, 0, read);

                left -= read;
            }

            setParameter(i, out.toByteArray());
        } catch (IOException e) {
            throw Util.sqlException(Trace.INPUTSTREAM_ERROR, e.toString());
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {}
            }
        }
    }
View Full Code Here

            int length = row.getStorageSize()
                         - ScriptWriterText.BYTES_LINE_SEP.length;

            rowOut.reset();

            HsqlByteArrayOutputStream out = rowOut.getOutputStream();

            out.fill(' ', length);
            out.write(ScriptWriterText.BYTES_LINE_SEP);
            dataFile.seek(row.getPos());
            dataFile.write(out.getBuffer(), 0, out.size());
        } catch (IOException e) {
            throw Error.runtimeError(ErrorCode.U_S0500, e.getMessage());
        }
    }
View Full Code Here

        this.file      = new RandomAccessFile(name, accessMode);
        buffer         = new byte[bufferSize];
        ba             = new HsqlByteArrayInputStream(buffer);
        valueBuffer    = new byte[8];
        vbao           = new HsqlByteArrayOutputStream(valueBuffer);
        vbai           = new HsqlByteArrayInputStream(valueBuffer);
        fileDescriptor = file.getFD();
        fileLength     = length();

        readIntoBuffer();
View Full Code Here

        try {
            Exception e = new Exception();

            throw e;
        } catch (Exception e) {
            HsqlByteArrayOutputStream os = new HsqlByteArrayOutputStream();
            PrintWriter               pw = new PrintWriter(os, true);

            e.printStackTrace(pw);

            return os.toString();
        }
    }
View Full Code Here

        dataOut.writeInt(databaseID);
        dataOut.writeLong(sessionID);
        dataOut.writeLong(lobID);
        dataOut.writeInt(subType);

        HsqlByteArrayOutputStream byteArrayOS =
            new HsqlByteArrayOutputStream(bufferLength);

        byteArrayOS.reset();
        byteArrayOS.write(stream, bufferLength);
        dataOut.writeLong(currentOffset);
        dataOut.writeLong(byteArrayOS.size());
        dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

        currentOffset += byteArrayOS.size();

        if (byteArrayOS.size() < bufferLength) {
            return;
        }

        //
        while (true) {
            byteArrayOS.reset();
            byteArrayOS.write(stream, bufferLength);

            if (byteArrayOS.size() == 0) {
                break;
            }

            //
            dataOut.writeByte(mode);
            dataOut.writeInt(databaseID);
            dataOut.writeLong(sessionID);
            dataOut.writeLong(lobID);
            dataOut.writeInt(LobResultTypes.REQUEST_SET_BYTES);
            dataOut.writeLong(currentOffset);
            dataOut.writeLong(byteArrayOS.size());
            dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

            currentOffset += byteArrayOS.size();

            if (byteArrayOS.size() < bufferLength) {
                break;
            }
        }
    }
View Full Code Here

        dataOut.writeInt(databaseID);
        dataOut.writeLong(sessionID);
        dataOut.writeLong(lobID);
        dataOut.writeInt(subType);

        HsqlByteArrayOutputStream byteArrayOS =
            new HsqlByteArrayOutputStream(bufferLength);

        byteArrayOS.reset();
        byteArrayOS.write(reader, bufferLength / 2);

        //
        dataOut.writeLong(currentOffset);
        dataOut.writeLong(byteArrayOS.size() / 2);
        dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

        currentOffset += byteArrayOS.size() / 2;

        if (byteArrayOS.size() < bufferLength) {
            return;
        }

        //
        while (true) {
            byteArrayOS.reset();
            byteArrayOS.write(reader, bufferLength / 2);

            if (byteArrayOS.size() == 0) {
                break;
            }

            //
            dataOut.writeByte(mode);
            dataOut.writeInt(databaseID);
            dataOut.writeLong(sessionID);
            dataOut.writeLong(lobID);
            dataOut.writeInt(LobResultTypes.REQUEST_SET_CHARS);
            dataOut.writeLong(currentOffset);
            dataOut.writeLong(byteArrayOS.size() / 2);
            dataOut.write(byteArrayOS.getBuffer(), 0, byteArrayOS.size());

            currentOffset += byteArrayOS.size() / 2;

            if (byteArrayOS.size() < bufferLength) {
                break;
            }
        }
    }
View Full Code Here

                                      InputStream stream) throws IOException {

        //
        long currentOffset = result.getOffset();
        int  bufferLength  = session.getStreamBlockSize();
        HsqlByteArrayOutputStream byteArrayOS =
            new HsqlByteArrayOutputStream(bufferLength);

        while (true) {
            byteArrayOS.reset();
            byteArrayOS.write(stream, bufferLength);

            if (byteArrayOS.size() == 0) {
                return;
            }

            byte[] byteArray = byteArrayOS.getBuffer();
            Result actionResult =
                database.lobManager.setBytes(result.getLobID(), currentOffset,
                                             byteArray, byteArrayOS.size());

            currentOffset += byteArrayOS.size();

            if (byteArrayOS.size() < bufferLength) {
                return;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.hsqldb.lib.HsqlByteArrayOutputStream

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.