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;
}
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();
}
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());
}
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;
}
}
}
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();
}
Aggregations