Package net.sourceforge.jtds.util

Examples of net.sourceforge.jtds.util.BlobBuffer$AsciiInputStream


    BlobImpl(ConnectionJDBC2 connection, byte[] bytes) {
        if (bytes == null) {
            throw new IllegalArgumentException("bytes cannot be null");
        }

        blobBuffer = new BlobBuffer(connection.getBufferDir(), connection.getLobBuffer());
        blobBuffer.setBuffer(bytes, false);
    }
View Full Code Here


     */
    ClobImpl(ConnectionJDBC2 connection, String str) {
        if (str == null) {
            throw new IllegalArgumentException("str cannot be null");
        }
        blobBuffer = new BlobBuffer(connection.getBufferDir(), connection.getLobBuffer());
        try {
            byte[] data = str.getBytes("UTF-16LE");
            blobBuffer.setBuffer(data, false);
        } catch (UnsupportedEncodingException e) {
            // This should never happen!
View Full Code Here

    public long position(Clob searchStr, long start) throws SQLException {
        if (searchStr == null) {
            throw new SQLException(
                    Messages.get("error.clob.searchnull"), "HY009");
        }
        BlobBuffer bbuf = ((ClobImpl) searchStr).getBlobBuffer();
        byte[] pattern = bbuf.getBytes(1, (int) bbuf.getLength());
        int pos = blobBuffer.position(pattern, (start - 1) * 2 + 1);
        return (pos < 0) ? pos : (pos - 1) / 2 + 1;
    }
View Full Code Here

                        // Length of zero may indicate an initialized text
                        // column that has been updated to null.
                        break;
                    }
                    ClobImpl clob = new ClobImpl(connection);
                    BlobBuffer blobBuffer = clob.getBlobBuffer();
                    if (dataLen <= connection.getLobBuffer()) {
                        //
                        // OK Small enough to load into memory
                        //
                        BufferedReader rdr =
                            new BufferedReader(
                                 new InputStreamReader(in.getInputStream(dataLen),
                                                                         charset),
                                                                         1024);
                        byte[] data = new byte[dataLen * 2];
                        int p = 0;
                        int c;
                        while ((c = rdr.read()) >= 0) {
                            data[p++] = (byte)c;
                            data[p++] = (byte)(c >> 8);
                        }
                        rdr.close();
                        blobBuffer.setBuffer(data, false);
                        if (p == 2 && data[0] == 0x20 && data[1] == 0
                            && in.getTdsVersion() < Driver.TDS70) {
                            // Single space with Sybase equates to empty string
                            p = 0;
                        }
                        // Explicitly set length as multi byte character sets
                        // may not fill array completely.
                        blobBuffer.setLength(p);
                    } else {
                        // Too big, need to write straight to disk
                        BufferedReader rdr =
                            new BufferedReader(
                                 new InputStreamReader(in.getInputStream(dataLen),
                                                                         charset),
                                                                         1024);
                        try {
                            OutputStream out = blobBuffer.setBinaryStream(1, false);
                            int c;
                            while ((c = rdr.read()) >= 0) {
                                out.write(c);
                                out.write(c >> 8);
                            }
                            out.close();
                            rdr.close();
                        } catch (SQLException e) {
                            // Turn back into an IOException
                            throw new IOException(e.getMessage());
                        }
                    }
                    return clob;
                }

                break;

            case SYBUNITEXT: // ASE 15+ unicode text type
            case SYBNTEXT:
                len = in.read();

                if (len > 0) {
                    in.skip(24); // Skip textptr and timestamp
                    int dataLen = in.readInt();
                    if (dataLen == 0 && in.getTdsVersion() <= Driver.TDS50) {
                        // Length of zero may indicate an initialized unitext
                        // column that has been updated to null.
                        break;
                    }
                    ClobImpl clob = new ClobImpl(connection);
                    BlobBuffer blobBuffer = clob.getBlobBuffer();
                    if (dataLen <= connection.getLobBuffer()) {
                        //
                        // OK Small enough to load into memory
                        //
                        byte[] data = new byte[dataLen];
                        in.read(data);
                        blobBuffer.setBuffer(data, false);
                        if (dataLen == 2 && data[0] == 0x20 && data[1] == 0
                                && in.getTdsVersion() == Driver.TDS50) {
                                // Single space with Sybase equates to empty string
                                dataLen = 0;
                            }
                            // Explicitly set length as multi byte character sets
                            // may not fill array completely.
                            blobBuffer.setLength(dataLen);
                    } else {
                        // Too big, need to write straight to disk
                        try {
                            OutputStream out = blobBuffer.setBinaryStream(1, false);
                            byte[] buffer = new byte[1024];
                            int result;
                            while ((result = in.read(buffer, 0,
                                             Math.min(dataLen, buffer.length)))
                                             != -1 && dataLen != 0) {
View Full Code Here

TOP

Related Classes of net.sourceforge.jtds.util.BlobBuffer$AsciiInputStream

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.