use of org.hsqldb_voltpatches.types.BlobDataID 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;
}
}
}
use of org.hsqldb_voltpatches.types.BlobDataID in project voltdb by VoltDB.
the class LobManager method getBlob.
public BlobData getBlob(Session session, long lobID) {
Object[] data = getLobHeader(session, lobID);
if (data == null) {
return null;
}
BlobData blob = new BlobDataID(lobID);
return blob;
}
Aggregations