Search in sources :

Example 1 with ClobDataID

use of org.hsqldb_voltpatches.types.ClobDataID 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 2 with ClobDataID

use of org.hsqldb_voltpatches.types.ClobDataID in project voltdb by VoltDB.

the class LobManager method getClob.

public ClobData getClob(Session session, long lobID) {
    Object[] data = getLobHeader(session, lobID);
    if (data == null) {
        return null;
    }
    ClobData clob = new ClobDataID(lobID);
    return clob;
}
Also used : ClobDataID(org.hsqldb_voltpatches.types.ClobDataID) ClobData(org.hsqldb_voltpatches.types.ClobData)

Aggregations

ClobDataID (org.hsqldb_voltpatches.types.ClobDataID)2 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 SchemaObject (org.hsqldb_voltpatches.SchemaObject)1 CountdownInputStream (org.hsqldb_voltpatches.lib.CountdownInputStream)1 ResultLob (org.hsqldb_voltpatches.result.ResultLob)1 BlobDataID (org.hsqldb_voltpatches.types.BlobDataID)1 ClobData (org.hsqldb_voltpatches.types.ClobData)1