Package org.hsqldb.lib

Examples of org.hsqldb.lib.HsqlByteArrayOutputStream


            throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
        }

        try {
            java.io.InputStream in = x.getBinaryStream();
            HsqlByteArrayOutputStream out = new HsqlByteArrayOutputStream(in,
                (int) length);

            setParameter(parameterIndex, out.toByteArray());
        } catch (IOException e) {
            throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
                                    e.toString());
        }
    }
View Full Code Here


        checkSetParameterIndex(parameterIndex, true);

        if (parameterTypes[parameterIndex - 1].typeCode == Types.SQL_BLOB) {
            try {
                if (length < 0) {
                    HsqlByteArrayOutputStream output;

                    output = new HsqlByteArrayOutputStream(x);

                    JDBCBlob blob = new JDBCBlob(output.toByteArray());

                    setBlobParameter(parameterIndex, blob);

                    return;
                }
            } catch (IOException e) {
                throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
                                        e.toString());
            }
            streamLengths[parameterIndex - 1] = length;

            setParameter(parameterIndex, x);

            return;
        }

        try {
            if (length > Integer.MAX_VALUE) {
                String msg = "Maximum Blob input length exceeded: " + length;

                throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR, msg);
            }

            HsqlByteArrayOutputStream output;

            if (length < 0) {
                output = new HsqlByteArrayOutputStream(x);
            } else {
                output = new HsqlByteArrayOutputStream(x, (int) length);
            }
            setParameter(parameterIndex, output.toByteArray());
        } catch (IOException e) {
            throw Util.sqlException(ErrorCode.JDBC_INPUTSTREAM_ERROR,
                                    e.toString());
        }
    }
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

            return isBinary ? (Object) BinaryData.zeroLengthBinary
                            : "";
        }

        StringBuffer              sb = null;
        HsqlByteArrayOutputStream os = null;

        if (isBinary) {
            os = new HsqlByteArrayOutputStream();
        } else {
            sb = new StringBuffer();
        }

        int i = 0;

        for (; i < iLen && wildCardType[i] == 0; i++) {
            if (isBinary) {
                os.writeByte(cLike[i]);
            } else {
                sb.append(cLike[i]);
            }
        }

        if (i == 0) {
            return null;
        }

        return isBinary ? (Object) new BinaryData(os.toByteArray(), false)
                        : sb.toString();
    }
View Full Code Here

    public ScriptWriterEncode(Database db, String file, Crypto crypto) {

        super(db, file, false, false, false);

        this.crypto = crypto;
        byteOut     = new HsqlByteArrayOutputStream();
    }
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

                         + 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

        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

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

        return result;
    }

    protected void write(Result r) throws IOException, HsqlException {

        HsqlByteArrayOutputStream memStream  = new HsqlByteArrayOutputStream();
        DataOutputStream          tempOutput = new DataOutputStream(memStream);

        r.write(this, tempOutput, rowOut);
        httpConnection.setRequestMethod("POST");
        httpConnection.setDoOutput(true);
        httpConnection.setUseCaches(false);

        //httpConnection.setRequestProperty("Accept-Encoding", "gzip");
        httpConnection.setRequestProperty("Content-Type",
                                          "application/octet-stream");
        httpConnection.setRequestProperty("Content-Length",
                                          String.valueOf(IDLENGTH
                                              + memStream.size()));

        dataOutput = new DataOutputStream(httpConnection.getOutputStream());

        dataOutput.writeInt(r.getDatabaseId());
        dataOutput.writeLong(r.getSessionId());
        memStream.writeTo(dataOutput);
        dataOutput.flush();
    }
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.