Search in sources :

Example 6 with ResultLob

use of org.hsqldb_voltpatches.result.ResultLob in project voltdb by VoltDB.

the class ClobDataID method setChars.

public int setChars(SessionInterface session, long pos, char[] chars, int offset, int len) {
    if (!isInLimits(chars.length, offset, len)) {
        throw Error.error(ErrorCode.X_22001);
    }
    char[] newChars = new char[len];
    System.arraycopy(chars, offset, newChars, 0, len);
    ResultLob resultOut = ResultLob.newLobSetCharsRequest(id, pos, chars);
    Result resultIn = session.execute(resultOut);
    if (resultIn.isError()) {
        throw resultIn.getException();
    }
    return len;
}
Also used : ResultLob(org.hsqldb_voltpatches.result.ResultLob) Result(org.hsqldb_voltpatches.result.Result)

Example 7 with ResultLob

use of org.hsqldb_voltpatches.result.ResultLob in project voltdb by VoltDB.

the class ClobDataID method position.

public long position(SessionInterface session, String searchstr, long start) {
    ResultLob resultOut = ResultLob.newLobGetCharPatternPositionRequest(id, searchstr.toCharArray(), start);
    Result resultIn = session.execute(resultOut);
    if (resultIn.isError()) {
        throw resultIn.getException();
    }
    return ((ResultLob) resultIn).getOffset();
}
Also used : ResultLob(org.hsqldb_voltpatches.result.ResultLob) Result(org.hsqldb_voltpatches.result.Result)

Example 8 with ResultLob

use of org.hsqldb_voltpatches.result.ResultLob in project voltdb by VoltDB.

the class ClobDataID method getClob.

public ClobData getClob(SessionInterface session, long position, long length) {
    ResultLob resultOut = ResultLob.newLobGetRequest(id, position, length);
    Result resultIn = session.execute(resultOut);
    if (resultIn.isError()) {
        throw resultIn.getException();
    }
    return new ClobDataID(((ResultLob) resultIn).getLobID());
}
Also used : ResultLob(org.hsqldb_voltpatches.result.ResultLob) Result(org.hsqldb_voltpatches.result.Result)

Example 9 with ResultLob

use of org.hsqldb_voltpatches.result.ResultLob in project voltdb by VoltDB.

the class JDBCPreparedStatement method performPreExecute.

private void performPreExecute() throws SQLException, HsqlException {
    if (!hasLOBs) {
        return;
    }
    for (int i = 0; i < parameterValues.length; i++) {
        Object value = parameterValues[i];
        if (value == null) {
            continue;
        }
        if (parameterTypes[i].typeCode == Types.SQL_BLOB) {
            long id;
            BlobDataID blob = null;
            if (value instanceof JDBCBlobClient) {
                blob = ((JDBCBlobClient) value).blob;
                id = blob.getId();
            } else if (value instanceof Blob) {
                long length = ((Blob) value).length();
                blob = connection.sessionProxy.createBlob(length);
                id = blob.getId();
                InputStream stream = ((Blob) value).getBinaryStream();
                ResultLob resultLob = ResultLob.newLobCreateBlobRequest(connection.sessionProxy.getId(), id, stream, length);
                connection.sessionProxy.allocateResultLob(resultLob, null);
                resultOut.addLobResult(resultLob);
            } else if (value instanceof InputStream) {
                long length = streamLengths[i];
                blob = connection.sessionProxy.createBlob(length);
                id = blob.getId();
                InputStream stream = (InputStream) value;
                ResultLob resultLob = ResultLob.newLobCreateBlobRequest(connection.sessionProxy.getId(), id, stream, length);
                connection.sessionProxy.allocateResultLob(resultLob, null);
                resultOut.addLobResult(resultLob);
            }
            parameterValues[i] = blob;
        } else if (parameterTypes[i].typeCode == Types.SQL_CLOB) {
            long id;
            ClobDataID clob = null;
            if (value instanceof JDBCClobClient) {
                // fix id mismatch
                clob = ((JDBCClobClient) value).clob;
                id = clob.getId();
            } else if (value instanceof Clob) {
                long length = ((Clob) value).length();
                Reader reader = ((Clob) value).getCharacterStream();
                clob = connection.sessionProxy.createClob(length);
                id = clob.getId();
                ResultLob resultLob = ResultLob.newLobCreateClobRequest(connection.sessionProxy.getId(), id, reader, length);
                connection.sessionProxy.allocateResultLob(resultLob, null);
                resultOut.addLobResult(resultLob);
            } else if (value instanceof Reader) {
                long length = streamLengths[i];
                clob = connection.sessionProxy.createClob(length);
                id = clob.getId();
                Reader reader = (Reader) value;
                ResultLob resultLob = ResultLob.newLobCreateClobRequest(connection.sessionProxy.getId(), id, reader, length);
                connection.sessionProxy.allocateResultLob(resultLob, null);
                resultOut.addLobResult(resultLob);
            }
            parameterValues[i] = clob;
        }
    }
}
Also used : Blob(java.sql.Blob) ClobDataID(org.hsqldb_voltpatches.types.ClobDataID) CountdownInputStream(org.hsqldb_voltpatches.lib.CountdownInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) SchemaObject(org.hsqldb_voltpatches.SchemaObject) BlobDataID(org.hsqldb_voltpatches.types.BlobDataID) NClob(java.sql.NClob) Clob(java.sql.Clob) ResultLob(org.hsqldb_voltpatches.result.ResultLob)

Example 10 with ResultLob

use of org.hsqldb_voltpatches.result.ResultLob in project voltdb by VoltDB.

the class BlobDataID method getBytes.

public byte[] getBytes(SessionInterface session, long pos, int length) {
    ResultLob resultOut = ResultLob.newLobGetBytesRequest(id, pos, length);
    Result resultIn = session.execute(resultOut);
    if (resultIn.isError()) {
        throw Error.error(resultIn);
    }
    return ((ResultLob) resultIn).getByteArray();
}
Also used : ResultLob(org.hsqldb_voltpatches.result.ResultLob) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

ResultLob (org.hsqldb_voltpatches.result.ResultLob)15 Result (org.hsqldb_voltpatches.result.Result)13 EOFException (java.io.EOFException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 NClob (java.sql.NClob)1 HsqlException (org.hsqldb_voltpatches.HsqlException)1 SchemaObject (org.hsqldb_voltpatches.SchemaObject)1 CountdownInputStream (org.hsqldb_voltpatches.lib.CountdownInputStream)1 HsqlByteArrayInputStream (org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream)1 BlobDataID (org.hsqldb_voltpatches.types.BlobDataID)1 ClobDataID (org.hsqldb_voltpatches.types.ClobDataID)1